@forsakringskassan/vitest-config 2.7.0 → 2.8.0
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.
- package/dist/index.js +98 -19
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -132,7 +132,12 @@ var require_cjs = __commonJS({
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
// ../../node_modules/@vitest/coverage-v8/dist/index.js
|
|
135
|
+
import assert from "node:assert";
|
|
136
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
137
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
138
|
+
import { readdir, readFile, rm } from "node:fs/promises";
|
|
135
139
|
import inspector from "node:inspector/promises";
|
|
140
|
+
import { resolve as resolve2 } from "node:path";
|
|
136
141
|
import { fileURLToPath } from "node:url";
|
|
137
142
|
|
|
138
143
|
// ../../node_modules/std-env/dist/index.mjs
|
|
@@ -192,17 +197,10 @@ function I() {
|
|
|
192
197
|
var L = I();
|
|
193
198
|
var R = L?.name || ``;
|
|
194
199
|
|
|
195
|
-
// ../../node_modules/@vitest/coverage-v8/dist/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
/* @vite-ignore */
|
|
200
|
-
name
|
|
201
|
-
);
|
|
202
|
-
return new V8CoverageProvider();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// ../../node_modules/@vitest/coverage-v8/dist/pathe.M-eThtNZ-BTaAGrLg.js
|
|
200
|
+
// ../../node_modules/@vitest/coverage-v8/dist/commands-wCiafWY1.js
|
|
201
|
+
import { randomUUID } from "node:crypto";
|
|
202
|
+
import { existsSync } from "node:fs";
|
|
203
|
+
import { writeFile } from "node:fs/promises";
|
|
206
204
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
207
205
|
function normalizeWindowsPath(input = "") {
|
|
208
206
|
if (!input) {
|
|
@@ -242,6 +240,30 @@ var normalize = function(path) {
|
|
|
242
240
|
}
|
|
243
241
|
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
244
242
|
};
|
|
243
|
+
function cwd() {
|
|
244
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
245
|
+
return process.cwd().replace(/\\/g, "/");
|
|
246
|
+
}
|
|
247
|
+
return "/";
|
|
248
|
+
}
|
|
249
|
+
var resolve = function(...arguments_) {
|
|
250
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
251
|
+
let resolvedPath = "";
|
|
252
|
+
let resolvedAbsolute = false;
|
|
253
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
254
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
255
|
+
if (!path || path.length === 0) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
259
|
+
resolvedAbsolute = isAbsolute(path);
|
|
260
|
+
}
|
|
261
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
262
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
263
|
+
return `/${resolvedPath}`;
|
|
264
|
+
}
|
|
265
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
266
|
+
};
|
|
245
267
|
function normalizeString(path, allowAboveRoot) {
|
|
246
268
|
let res = "";
|
|
247
269
|
let lastSegmentLength = 0;
|
|
@@ -305,16 +327,45 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
305
327
|
var isAbsolute = function(p2) {
|
|
306
328
|
return _IS_ABSOLUTE_RE.test(p2);
|
|
307
329
|
};
|
|
330
|
+
async function writeCoverageFile(coverageFilesDirectory, coverage) {
|
|
331
|
+
const filename = resolve(coverageFilesDirectory, `coverage-${randomUUID()}.json`);
|
|
332
|
+
try {
|
|
333
|
+
await writeFile(filename, JSON.stringify(coverage), "utf-8");
|
|
334
|
+
} catch (error) {
|
|
335
|
+
if (!existsSync(coverageFilesDirectory)) {
|
|
336
|
+
throw new Error(`Something removed the coverage directory "${coverageFilesDirectory}" Vitest created earlier. Make sure you are not running multiple Vitests with the same "coverage.reportsDirectory" at the same time.`, { cause: error });
|
|
337
|
+
}
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
return filename;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// ../../node_modules/@vitest/coverage-v8/dist/load-provider-CdgAx3rL.js
|
|
344
|
+
var name = "./provider.js";
|
|
345
|
+
async function loadProvider() {
|
|
346
|
+
const { V8CoverageProvider } = await import(
|
|
347
|
+
/* @vite-ignore */
|
|
348
|
+
name
|
|
349
|
+
);
|
|
350
|
+
return new V8CoverageProvider();
|
|
351
|
+
}
|
|
308
352
|
|
|
309
353
|
// ../../node_modules/@vitest/coverage-v8/dist/index.js
|
|
310
|
-
var session = new inspector.Session();
|
|
311
354
|
var enabled = false;
|
|
312
355
|
var mod = {
|
|
313
|
-
|
|
356
|
+
extendedContextCoverageDir: void 0,
|
|
357
|
+
session: null,
|
|
358
|
+
async startCoverage({ isolate, autoAttachSubprocess, reportsDirectory }) {
|
|
314
359
|
if (isolate === false && enabled) {
|
|
315
360
|
return;
|
|
316
361
|
}
|
|
317
362
|
enabled = true;
|
|
363
|
+
if (autoAttachSubprocess) {
|
|
364
|
+
this.extendedContextCoverageDir = resolve2(reportsDirectory, "tmp", randomUUID2());
|
|
365
|
+
process.env.NODE_V8_COVERAGE = this.extendedContextCoverageDir;
|
|
366
|
+
}
|
|
367
|
+
this.session ||= new inspector.Session();
|
|
368
|
+
const session = this.session;
|
|
318
369
|
session.connect();
|
|
319
370
|
await session.post("Profiler.enable");
|
|
320
371
|
await session.post("Profiler.startPreciseCoverage", {
|
|
@@ -324,27 +375,55 @@ var mod = {
|
|
|
324
375
|
},
|
|
325
376
|
async takeCoverage(options) {
|
|
326
377
|
if (f === "stackblitz") {
|
|
327
|
-
return
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const session = this.session;
|
|
381
|
+
if (!session) {
|
|
382
|
+
throw new Error("V8 provider missing inspector session.");
|
|
328
383
|
}
|
|
329
384
|
const coverage = await session.post("Profiler.takePreciseCoverage");
|
|
330
385
|
const result = [];
|
|
331
386
|
for (const entry of coverage.result) {
|
|
332
387
|
if (filterResult(entry)) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
startOffset: options?.moduleExecutionInfo?.get(normalize(fileURLToPath(entry.url)))?.startOffset || 0
|
|
336
|
-
});
|
|
388
|
+
entry.startOffset = options?.moduleExecutionInfo?.get(normalize(fileURLToPath(entry.url)))?.startOffset || 0;
|
|
389
|
+
result.push(entry);
|
|
337
390
|
}
|
|
338
391
|
}
|
|
339
|
-
|
|
392
|
+
if (this.extendedContextCoverageDir && existsSync2(this.extendedContextCoverageDir)) {
|
|
393
|
+
const filenames = await readdir(this.extendedContextCoverageDir);
|
|
394
|
+
const contents = await Promise.all(filenames.filter((filename) => filename.endsWith(".json")).map(async (filename) => {
|
|
395
|
+
const path = `${this.extendedContextCoverageDir}/${filename}`;
|
|
396
|
+
const content = await readFile(path, "utf8");
|
|
397
|
+
await rm(path);
|
|
398
|
+
return content;
|
|
399
|
+
}));
|
|
400
|
+
for (const content of contents) {
|
|
401
|
+
const json = JSON.parse(content);
|
|
402
|
+
for (const entry of json.result) {
|
|
403
|
+
if (filterResult(entry)) {
|
|
404
|
+
entry.startOffset = 0;
|
|
405
|
+
entry.isExtendedContext = true;
|
|
406
|
+
result.push(entry);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
const coverageFilesDirectory = options?.coverageFilesDirectory;
|
|
412
|
+
assert(coverageFilesDirectory, "coverageFilesDirectory is required");
|
|
413
|
+
return await writeCoverageFile(coverageFilesDirectory, { result });
|
|
340
414
|
},
|
|
341
415
|
async stopCoverage({ isolate }) {
|
|
342
416
|
if (isolate === false) {
|
|
343
417
|
return;
|
|
344
418
|
}
|
|
419
|
+
const session = this.session;
|
|
420
|
+
if (!session) {
|
|
421
|
+
throw new Error("V8 provider missing inspector session.");
|
|
422
|
+
}
|
|
345
423
|
await session.post("Profiler.stopPreciseCoverage");
|
|
346
424
|
await session.post("Profiler.disable");
|
|
347
425
|
session.disconnect();
|
|
426
|
+
this.session = null;
|
|
348
427
|
},
|
|
349
428
|
async getProvider() {
|
|
350
429
|
return loadProvider();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/vitest-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Försäkringskassan shareable config for Vitest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vitest"
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"prepublishOnly": "release-prepublish --bundle --retain-scripts"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@vitest/coverage-v8": "^
|
|
37
|
+
"@vitest/coverage-v8": "^5.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"vitest": "^4.0.0"
|
|
40
|
+
"vitest": "^4.0.0 || ^5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">= 22.12.0",
|
|
44
44
|
"npm": ">= 10.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "c4a0bf7f4e2a8a9d6cb8362b5ec937c6952d21b3"
|
|
47
47
|
}
|