@forsakringskassan/vitest-config 1.1.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import { type TestUserConfig } from "vitest/config";
2
+ export declare function defineTestConfig(userConfig?: TestUserConfig): TestUserConfig;
package/dist/index.js ADDED
@@ -0,0 +1,396 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod2) => function __require() {
8
+ return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
24
+ mod2
25
+ ));
26
+
27
+ // ../../node_modules/deepmerge/dist/cjs.js
28
+ var require_cjs = __commonJS({
29
+ "../../node_modules/deepmerge/dist/cjs.js"(exports, module) {
30
+ "use strict";
31
+ var isMergeableObject = function isMergeableObject2(value) {
32
+ return isNonNullObject(value) && !isSpecial(value);
33
+ };
34
+ function isNonNullObject(value) {
35
+ return !!value && typeof value === "object";
36
+ }
37
+ function isSpecial(value) {
38
+ var stringValue = Object.prototype.toString.call(value);
39
+ return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
40
+ }
41
+ var canUseSymbol = typeof Symbol === "function" && Symbol.for;
42
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
43
+ function isReactElement(value) {
44
+ return value.$$typeof === REACT_ELEMENT_TYPE;
45
+ }
46
+ function emptyTarget(val) {
47
+ return Array.isArray(val) ? [] : {};
48
+ }
49
+ function cloneUnlessOtherwiseSpecified(value, options) {
50
+ return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
51
+ }
52
+ function defaultArrayMerge(target, source, options) {
53
+ return target.concat(source).map(function(element) {
54
+ return cloneUnlessOtherwiseSpecified(element, options);
55
+ });
56
+ }
57
+ function getMergeFunction(key, options) {
58
+ if (!options.customMerge) {
59
+ return deepmerge2;
60
+ }
61
+ var customMerge = options.customMerge(key);
62
+ return typeof customMerge === "function" ? customMerge : deepmerge2;
63
+ }
64
+ function getEnumerableOwnPropertySymbols(target) {
65
+ return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
66
+ return Object.propertyIsEnumerable.call(target, symbol);
67
+ }) : [];
68
+ }
69
+ function getKeys(target) {
70
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
71
+ }
72
+ function propertyIsOnObject(object, property) {
73
+ try {
74
+ return property in object;
75
+ } catch (_2) {
76
+ return false;
77
+ }
78
+ }
79
+ function propertyIsUnsafe(target, key) {
80
+ return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
81
+ }
82
+ function mergeObject(target, source, options) {
83
+ var destination = {};
84
+ if (options.isMergeableObject(target)) {
85
+ getKeys(target).forEach(function(key) {
86
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
87
+ });
88
+ }
89
+ getKeys(source).forEach(function(key) {
90
+ if (propertyIsUnsafe(target, key)) {
91
+ return;
92
+ }
93
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
94
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
95
+ } else {
96
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
97
+ }
98
+ });
99
+ return destination;
100
+ }
101
+ function deepmerge2(target, source, options) {
102
+ options = options || {};
103
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
104
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
105
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
106
+ var sourceIsArray = Array.isArray(source);
107
+ var targetIsArray = Array.isArray(target);
108
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
109
+ if (!sourceAndTargetTypesMatch) {
110
+ return cloneUnlessOtherwiseSpecified(source, options);
111
+ } else if (sourceIsArray) {
112
+ return options.arrayMerge(target, source, options);
113
+ } else {
114
+ return mergeObject(target, source, options);
115
+ }
116
+ }
117
+ deepmerge2.all = function deepmergeAll(array, options) {
118
+ if (!Array.isArray(array)) {
119
+ throw new Error("first argument should be an array");
120
+ }
121
+ return array.reduce(function(prev, next) {
122
+ return deepmerge2(prev, next, options);
123
+ }, {});
124
+ };
125
+ var deepmerge_1 = deepmerge2;
126
+ module.exports = deepmerge_1;
127
+ }
128
+ });
129
+
130
+ // ../../node_modules/@vitest/coverage-v8/dist/index.js
131
+ import inspector from "node:inspector/promises";
132
+ import { fileURLToPath } from "node:url";
133
+
134
+ // ../../node_modules/std-env/dist/index.mjs
135
+ var r = /* @__PURE__ */ Object.create(null);
136
+ var i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
137
+ var o = new Proxy(r, { get(e, s) {
138
+ return i()[s] ?? r[s];
139
+ }, has(e, s) {
140
+ const E = i();
141
+ return s in E || s in r;
142
+ }, set(e, s, E) {
143
+ const B = i(true);
144
+ return B[s] = E, true;
145
+ }, deleteProperty(e, s) {
146
+ if (!s)
147
+ return false;
148
+ const E = i(true);
149
+ return delete E[s], true;
150
+ }, ownKeys() {
151
+ const e = i(true);
152
+ return Object.keys(e);
153
+ } });
154
+ var t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
155
+ var f = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CLOUDFLARE_WORKERS", "WORKERS_CI", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
156
+ function b() {
157
+ if (globalThis.process?.env)
158
+ for (const e of f) {
159
+ const s = e[1] || e[0];
160
+ if (globalThis.process?.env[s])
161
+ return { name: e[0].toLowerCase(), ...e[2] };
162
+ }
163
+ return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
164
+ }
165
+ var l = b();
166
+ var p = l.name;
167
+ function n(e) {
168
+ return e ? e !== "false" : false;
169
+ }
170
+ var I = globalThis.process?.platform || "";
171
+ var T = n(o.CI) || l.ci !== false;
172
+ var R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
173
+ var d = n(o.DEBUG);
174
+ var a = t === "test" || n(o.TEST);
175
+ var v = n(o.MINIMAL) || T || a || !R;
176
+ var A = /^win/i.test(I);
177
+ var M = /^linux/i.test(I);
178
+ var m = /^darwin/i.test(I);
179
+ var Y = !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (R || A) && o.TERM !== "dumb" || T);
180
+ var C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
181
+ var V = Number(C?.split(".")[0]) || null;
182
+ var W = globalThis.process || /* @__PURE__ */ Object.create(null);
183
+ var _ = { versions: {} };
184
+ var y = new Proxy(W, { get(e, s) {
185
+ if (s === "env")
186
+ return o;
187
+ if (s in e)
188
+ return e[s];
189
+ if (s in _)
190
+ return _[s];
191
+ } });
192
+ var O = globalThis.process?.release?.name === "node";
193
+ var c = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
194
+ var D = !!globalThis.Deno;
195
+ var L = !!globalThis.fastly;
196
+ var S = !!globalThis.Netlify;
197
+ var u = !!globalThis.EdgeRuntime;
198
+ var N = globalThis.navigator?.userAgent === "Cloudflare-Workers";
199
+ var F = [[S, "netlify"], [u, "edge-light"], [N, "workerd"], [L, "fastly"], [D, "deno"], [c, "bun"], [O, "node"]];
200
+ function G() {
201
+ const e = F.find((s) => s[0]);
202
+ if (e)
203
+ return { name: e[1] };
204
+ }
205
+ var P = G();
206
+ var K = P?.name || "";
207
+
208
+ // ../../node_modules/@vitest/coverage-v8/dist/load-provider-CdgAx3rL.js
209
+ var name = "./provider.js";
210
+ async function loadProvider() {
211
+ const { V8CoverageProvider } = await import(
212
+ /* @vite-ignore */
213
+ name
214
+ );
215
+ return new V8CoverageProvider();
216
+ }
217
+
218
+ // ../../node_modules/@vitest/coverage-v8/dist/pathe.M-eThtNZ-BTaAGrLg.js
219
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
220
+ function normalizeWindowsPath(input = "") {
221
+ if (!input) {
222
+ return input;
223
+ }
224
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r2) => r2.toUpperCase());
225
+ }
226
+ var _UNC_REGEX = /^[/\\]{2}/;
227
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
228
+ var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
229
+ var normalize = function(path) {
230
+ if (path.length === 0) {
231
+ return ".";
232
+ }
233
+ path = normalizeWindowsPath(path);
234
+ const isUNCPath = path.match(_UNC_REGEX);
235
+ const isPathAbsolute = isAbsolute(path);
236
+ const trailingSeparator = path[path.length - 1] === "/";
237
+ path = normalizeString(path, !isPathAbsolute);
238
+ if (path.length === 0) {
239
+ if (isPathAbsolute) {
240
+ return "/";
241
+ }
242
+ return trailingSeparator ? "./" : ".";
243
+ }
244
+ if (trailingSeparator) {
245
+ path += "/";
246
+ }
247
+ if (_DRIVE_LETTER_RE.test(path)) {
248
+ path += "/";
249
+ }
250
+ if (isUNCPath) {
251
+ if (!isPathAbsolute) {
252
+ return `//./${path}`;
253
+ }
254
+ return `//${path}`;
255
+ }
256
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
257
+ };
258
+ function normalizeString(path, allowAboveRoot) {
259
+ let res = "";
260
+ let lastSegmentLength = 0;
261
+ let lastSlash = -1;
262
+ let dots = 0;
263
+ let char = null;
264
+ for (let index = 0; index <= path.length; ++index) {
265
+ if (index < path.length) {
266
+ char = path[index];
267
+ } else if (char === "/") {
268
+ break;
269
+ } else {
270
+ char = "/";
271
+ }
272
+ if (char === "/") {
273
+ if (lastSlash === index - 1 || dots === 1)
274
+ ;
275
+ else if (dots === 2) {
276
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
277
+ if (res.length > 2) {
278
+ const lastSlashIndex = res.lastIndexOf("/");
279
+ if (lastSlashIndex === -1) {
280
+ res = "";
281
+ lastSegmentLength = 0;
282
+ } else {
283
+ res = res.slice(0, lastSlashIndex);
284
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
285
+ }
286
+ lastSlash = index;
287
+ dots = 0;
288
+ continue;
289
+ } else if (res.length > 0) {
290
+ res = "";
291
+ lastSegmentLength = 0;
292
+ lastSlash = index;
293
+ dots = 0;
294
+ continue;
295
+ }
296
+ }
297
+ if (allowAboveRoot) {
298
+ res += res.length > 0 ? "/.." : "..";
299
+ lastSegmentLength = 2;
300
+ }
301
+ } else {
302
+ if (res.length > 0) {
303
+ res += `/${path.slice(lastSlash + 1, index)}`;
304
+ } else {
305
+ res = path.slice(lastSlash + 1, index);
306
+ }
307
+ lastSegmentLength = index - lastSlash - 1;
308
+ }
309
+ lastSlash = index;
310
+ dots = 0;
311
+ } else if (char === "." && dots !== -1) {
312
+ ++dots;
313
+ } else {
314
+ dots = -1;
315
+ }
316
+ }
317
+ return res;
318
+ }
319
+ var isAbsolute = function(p2) {
320
+ return _IS_ABSOLUTE_RE.test(p2);
321
+ };
322
+
323
+ // ../../node_modules/@vitest/coverage-v8/dist/index.js
324
+ var session = new inspector.Session();
325
+ var enabled = false;
326
+ var mod = {
327
+ async startCoverage({ isolate }) {
328
+ if (isolate === false && enabled) {
329
+ return;
330
+ }
331
+ enabled = true;
332
+ session.connect();
333
+ await session.post("Profiler.enable");
334
+ await session.post("Profiler.startPreciseCoverage", {
335
+ callCount: true,
336
+ detailed: true
337
+ });
338
+ },
339
+ async takeCoverage(options) {
340
+ if (p === "stackblitz") {
341
+ return { result: [] };
342
+ }
343
+ const coverage = await session.post("Profiler.takePreciseCoverage");
344
+ const result = [];
345
+ for (const entry of coverage.result) {
346
+ if (filterResult(entry)) {
347
+ result.push({
348
+ ...entry,
349
+ startOffset: options?.moduleExecutionInfo?.get(normalize(fileURLToPath(entry.url)))?.startOffset || 0
350
+ });
351
+ }
352
+ }
353
+ return { result };
354
+ },
355
+ async stopCoverage({ isolate }) {
356
+ if (isolate === false) {
357
+ return;
358
+ }
359
+ await session.post("Profiler.stopPreciseCoverage");
360
+ await session.post("Profiler.disable");
361
+ session.disconnect();
362
+ },
363
+ async getProvider() {
364
+ return loadProvider();
365
+ }
366
+ };
367
+ function filterResult(coverage) {
368
+ if (!coverage.url.startsWith("file://")) {
369
+ return false;
370
+ }
371
+ if (coverage.url.includes("/node_modules/")) {
372
+ return false;
373
+ }
374
+ return true;
375
+ }
376
+
377
+ // src/index.ts
378
+ var import_deepmerge = __toESM(require_cjs(), 1);
379
+ function overwriteMerge(_a, b2) {
380
+ return b2;
381
+ }
382
+ function defineTestConfig(userConfig = {}) {
383
+ const defaultConfig = {
384
+ coverage: {
385
+ provider: mod,
386
+ reporter: ["text", "text-summary", "lcov"],
387
+ include: ["src/**/*.[jt]s"],
388
+ exclude: ["**/index.[jt]s"]
389
+ }
390
+ };
391
+ const resolvedConfig = userConfig ? (0, import_deepmerge.default)(defaultConfig, userConfig, { arrayMerge: overwriteMerge }) : defaultConfig;
392
+ return resolvedConfig;
393
+ }
394
+ export {
395
+ defineTestConfig
396
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vitest-config",
3
- "version": "1.1.0",
3
+ "version": "2.0.1",
4
4
  "description": "Försäkringskassan shareable config for Vitest",
5
5
  "keywords": [
6
6
  "vitest"
@@ -11,27 +11,33 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/Forsakringskassan/vitest-config.git"
14
+ "url": "git+https://github.com/Forsakringskassan/vitest-config.git",
15
+ "directory": "packages/vitest-config"
15
16
  },
16
17
  "license": "MIT",
17
18
  "author": "Föräkringskassan",
18
19
  "type": "module",
19
- "main": "index.mjs",
20
- "types": "index.d.mts",
20
+ "main": "dist/index.js",
21
+ "types": "dist/index.d.ts",
21
22
  "bin": {
22
23
  "vitest": "vitest.mjs"
23
24
  },
24
25
  "files": [
25
- "index.mjs",
26
- "index.d.mts",
27
- "vitest.mjs"
26
+ "dist/"
28
27
  ],
29
- "dependencies": {
30
- "@vitest/coverage-v8": "4.0.18",
31
- "vitest": "4.0.18"
28
+ "scripts": {
29
+ "prebuild": "tsc",
30
+ "build": "node build.mjs",
31
+ "prepack": "release-prepack --bundle --retain-scripts",
32
+ "postpack": "release-postpack",
33
+ "prepublishOnly": "release-prepublish --bundle --retain-scripts"
34
+ },
35
+ "peerDependencies": {
36
+ "vitest": "^4.0.0"
32
37
  },
33
38
  "engines": {
34
- "node": ">= 20",
35
- "npm": ">= 7"
36
- }
39
+ "node": ">= 22.12.0",
40
+ "npm": ">= 10.0.0"
41
+ },
42
+ "gitHead": "eca59488edbc3f414a041e84aeb850f08be10f7c"
37
43
  }
package/README.md DELETED
@@ -1,22 +0,0 @@
1
- # @forsakringskassan/vitest-config
2
-
3
- > Försäkringskassan shareable config for Vitest
4
-
5
- ## Installation
6
-
7
- `npm install --save-dev @forsakringskassan/vitest-config`
8
-
9
- In vitest.config.js:
10
-
11
- ```diff
12
- +import { defineTestConfig } from "@forsakringskassan/vitest-config";
13
- ...
14
- return {
15
- ...
16
- + test: defineTestConfig(),
17
- }
18
- ```
19
-
20
- You should not have vitest installed in your application, this preset bundles it. If you have it installed since earlier you can uninstall it:
21
-
22
- `npm rm vitest`
package/index.d.mts DELETED
@@ -1,9 +0,0 @@
1
- export function defineTestConfig(): {
2
- environment: string;
3
- coverage: {
4
- provider: "v8";
5
- reporter: string[];
6
- include: string[];
7
- exclude: string[];
8
- };
9
- };
package/index.mjs DELETED
@@ -1,13 +0,0 @@
1
- import provider from "@vitest/coverage-v8";
2
-
3
- export function defineTestConfig() {
4
- return {
5
- environment: "jsdom",
6
- coverage: {
7
- provider: /** @type {"v8"} */ (/** @type {unknown} */ (provider)),
8
- reporter: ["text", "text-summary", "lcov"],
9
- include: ["src/**/*.[jt]s"],
10
- exclude: ["**/index.[jt]s"],
11
- },
12
- };
13
- }
package/vitest.mjs DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawn } from "node:child_process";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
-
7
- const pkgPath = path.dirname(
8
- fileURLToPath(import.meta.resolve("vitest/package.json")),
9
- );
10
- const binary = path.join(pkgPath, "vitest.mjs");
11
-
12
- /* eslint-disable-next-line sonarjs/no-os-command-from-path -- want to execute node from PATH */
13
- spawn("node", [binary, ...process.argv.slice(2)], {
14
- stdio: "inherit",
15
- }).on("exit", (code) => {
16
- process.exit(code);
17
- });