vitest 0.0.114 → 0.0.115
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/LICENSE.md +5 -5
- package/dist/cli.js +1107 -31
- package/dist/{constants-9c7f06df.js → constants-5968a78c.js} +1 -1
- package/dist/{diff-3cfdad26.js → diff-67678e1f.js} +1 -1
- package/dist/entry.js +11 -11
- package/dist/{global-12653c72.js → global-bc40af7c.js} +4 -4
- package/dist/{index-61c8686f.js → index-648e7ab2.js} +62 -62
- package/dist/index-6e709f57.js +781 -0
- package/dist/{index-ea5153a0.js → index-7c024e16.js} +27 -2
- package/dist/{index-ebf35a56.js → index-7f57c252.js} +1 -1
- package/dist/{index-36694964.js → index-b4f86684.js} +143 -93
- package/dist/{index-9f4b9905.js → index-ce49e384.js} +33 -800
- package/dist/{index-7889832e.js → index-e909c175.js} +25 -16
- package/dist/index.d.ts +72 -9
- package/dist/index.js +3 -3
- package/dist/{middleware-85ff8fbf.js → middleware-647438b9.js} +2 -2
- package/dist/node.d.ts +70 -7
- package/dist/node.js +8 -7
- package/dist/rpc-8c7cc374.js +5 -0
- package/dist/utils.js +1 -1
- package/dist/{vi-67e478ef.js → vi-2115c609.js} +1 -2
- package/dist/worker.js +8 -7
- package/package.json +3 -2
- package/vitest.mjs +1 -20
- package/dist/rpc-85fe6402.js +0 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import {
|
|
2
|
+
import { k as resolve } from './index-7c024e16.js';
|
|
3
3
|
|
|
4
4
|
const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
5
5
|
const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
package/dist/entry.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import fs, { promises } from 'fs';
|
|
2
|
-
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, n as nanoid, l as clearContext, m as defaultSuite, o as setHooks, p as getHooks, q as context, s as setState, r as getFn, b as getState, e as vi } from './vi-
|
|
2
|
+
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, n as nanoid, l as clearContext, m as defaultSuite, o as setHooks, p as getHooks, q as context, s as setState, r as getFn, b as getState, e as vi } from './vi-2115c609.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
6
|
import chai$1, { expect, util } from 'chai';
|
|
7
7
|
import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
|
|
8
|
-
import {
|
|
9
|
-
import { r as rpc
|
|
10
|
-
import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-
|
|
8
|
+
import { q as index, s as slash, u as getNames, c as c$1, t as toArray, r as relative, v as interpretOnlyMode, w as partitionSuiteChildren, x as hasTests, h as hasFailed } from './index-7c024e16.js';
|
|
9
|
+
import { r as rpc } from './rpc-8c7cc374.js';
|
|
10
|
+
import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-67678e1f.js';
|
|
11
11
|
import { performance } from 'perf_hooks';
|
|
12
12
|
import { format as format$1 } from 'util';
|
|
13
13
|
import './jest-mock-4a754991.js';
|
|
@@ -387,7 +387,7 @@ async function saveInlineSnapshots(snapshots) {
|
|
|
387
387
|
const MagicString = (await import('./magic-string.es-94000aea.js')).default;
|
|
388
388
|
const files = new Set(snapshots.map((i) => i.file));
|
|
389
389
|
await Promise.all(Array.from(files).map(async (file) => {
|
|
390
|
-
const map = await rpc(
|
|
390
|
+
const map = await rpc().getSourceMap(file);
|
|
391
391
|
const snaps = snapshots.filter((i) => i.file === file);
|
|
392
392
|
const code = await promises.readFile(file, "utf8");
|
|
393
393
|
const s = new MagicString(code);
|
|
@@ -3103,7 +3103,7 @@ class SnapshotClient {
|
|
|
3103
3103
|
if (!this.testFile || !this.snapshotState)
|
|
3104
3104
|
return;
|
|
3105
3105
|
const result = await packSnapshotState(this.testFile, this.snapshotState);
|
|
3106
|
-
await rpc(
|
|
3106
|
+
await rpc().snapshotSaved(result);
|
|
3107
3107
|
this.testFile = "";
|
|
3108
3108
|
this.snapshotState = void 0;
|
|
3109
3109
|
}
|
|
@@ -3530,13 +3530,13 @@ async function setupGlobalEnv(config) {
|
|
|
3530
3530
|
setupConsoleLogSpy();
|
|
3531
3531
|
await setupChai();
|
|
3532
3532
|
if (config.global)
|
|
3533
|
-
(await import('./global-
|
|
3533
|
+
(await import('./global-bc40af7c.js')).registerApiGlobally();
|
|
3534
3534
|
}
|
|
3535
3535
|
function setupConsoleLogSpy() {
|
|
3536
3536
|
const stdout = new Writable({
|
|
3537
3537
|
write(data, encoding, callback) {
|
|
3538
3538
|
var _a;
|
|
3539
|
-
|
|
3539
|
+
rpc().onUserLog({
|
|
3540
3540
|
type: "stdout",
|
|
3541
3541
|
content: String(data),
|
|
3542
3542
|
taskId: (_a = process.__vitest_worker__.current) == null ? void 0 : _a.id
|
|
@@ -3547,7 +3547,7 @@ function setupConsoleLogSpy() {
|
|
|
3547
3547
|
const stderr = new Writable({
|
|
3548
3548
|
write(data, encoding, callback) {
|
|
3549
3549
|
var _a;
|
|
3550
|
-
|
|
3550
|
+
rpc().onUserLog({
|
|
3551
3551
|
type: "stderr",
|
|
3552
3552
|
content: String(data),
|
|
3553
3553
|
taskId: (_a = process.__vitest_worker__.current) == null ? void 0 : _a.id
|
|
@@ -3662,7 +3662,7 @@ async function callSuiteHook(suite, name, args) {
|
|
|
3662
3662
|
await callSuiteHook(suite.suite, name, args);
|
|
3663
3663
|
}
|
|
3664
3664
|
function updateTask(task) {
|
|
3665
|
-
return rpc(
|
|
3665
|
+
return rpc().onTaskUpdate([task.id, task.result]);
|
|
3666
3666
|
}
|
|
3667
3667
|
async function runTest(test) {
|
|
3668
3668
|
if (test.mode !== "run")
|
|
@@ -3761,7 +3761,7 @@ async function runSuites(suites) {
|
|
|
3761
3761
|
}
|
|
3762
3762
|
async function startTests(paths, config) {
|
|
3763
3763
|
const files = await collectTests(paths, config);
|
|
3764
|
-
|
|
3764
|
+
rpc().onCollected(files);
|
|
3765
3765
|
await runSuites(files);
|
|
3766
3766
|
await getSnapshotClient().saveSnap();
|
|
3767
3767
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-5968a78c.js';
|
|
2
|
+
import { i as index } from './index-7f57c252.js';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './index-
|
|
4
|
+
import './index-7c024e16.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './vi-
|
|
8
|
+
import './vi-2115c609.js';
|
|
9
9
|
import './_commonjsHelpers-c9e3b764.js';
|
|
10
10
|
import './jest-mock-4a754991.js';
|
|
11
11
|
import 'chai';
|
|
@@ -2,68 +2,6 @@ import { c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
|
|
|
2
2
|
import assert$1 from 'assert';
|
|
3
3
|
import require$$2 from 'events';
|
|
4
4
|
|
|
5
|
-
var onetime$2 = {exports: {}};
|
|
6
|
-
|
|
7
|
-
var mimicFn$2 = {exports: {}};
|
|
8
|
-
|
|
9
|
-
const mimicFn$1 = (to, from) => {
|
|
10
|
-
for (const prop of Reflect.ownKeys(from)) {
|
|
11
|
-
Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
mimicFn$2.exports = mimicFn$1;
|
|
18
|
-
// TODO: Remove this for the next major release
|
|
19
|
-
mimicFn$2.exports.default = mimicFn$1;
|
|
20
|
-
|
|
21
|
-
const mimicFn = mimicFn$2.exports;
|
|
22
|
-
|
|
23
|
-
const calledFunctions = new WeakMap();
|
|
24
|
-
|
|
25
|
-
const onetime = (function_, options = {}) => {
|
|
26
|
-
if (typeof function_ !== 'function') {
|
|
27
|
-
throw new TypeError('Expected a function');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let returnValue;
|
|
31
|
-
let callCount = 0;
|
|
32
|
-
const functionName = function_.displayName || function_.name || '<anonymous>';
|
|
33
|
-
|
|
34
|
-
const onetime = function (...arguments_) {
|
|
35
|
-
calledFunctions.set(onetime, ++callCount);
|
|
36
|
-
|
|
37
|
-
if (callCount === 1) {
|
|
38
|
-
returnValue = function_.apply(this, arguments_);
|
|
39
|
-
function_ = null;
|
|
40
|
-
} else if (options.throw === true) {
|
|
41
|
-
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return returnValue;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
mimicFn(onetime, function_);
|
|
48
|
-
calledFunctions.set(onetime, callCount);
|
|
49
|
-
|
|
50
|
-
return onetime;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
onetime$2.exports = onetime;
|
|
54
|
-
// TODO: Remove this for the next major release
|
|
55
|
-
onetime$2.exports.default = onetime;
|
|
56
|
-
|
|
57
|
-
onetime$2.exports.callCount = function_ => {
|
|
58
|
-
if (!calledFunctions.has(function_)) {
|
|
59
|
-
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return calledFunctions.get(function_);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
var onetime$1 = onetime$2.exports;
|
|
66
|
-
|
|
67
5
|
var signalExit$1 = {exports: {}};
|
|
68
6
|
|
|
69
7
|
var signals$1 = {exports: {}};
|
|
@@ -327,4 +265,66 @@ if (!processOk(process$1)) {
|
|
|
327
265
|
|
|
328
266
|
var signalExit = signalExit$1.exports;
|
|
329
267
|
|
|
268
|
+
var onetime$2 = {exports: {}};
|
|
269
|
+
|
|
270
|
+
var mimicFn$2 = {exports: {}};
|
|
271
|
+
|
|
272
|
+
const mimicFn$1 = (to, from) => {
|
|
273
|
+
for (const prop of Reflect.ownKeys(from)) {
|
|
274
|
+
Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return to;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
mimicFn$2.exports = mimicFn$1;
|
|
281
|
+
// TODO: Remove this for the next major release
|
|
282
|
+
mimicFn$2.exports.default = mimicFn$1;
|
|
283
|
+
|
|
284
|
+
const mimicFn = mimicFn$2.exports;
|
|
285
|
+
|
|
286
|
+
const calledFunctions = new WeakMap();
|
|
287
|
+
|
|
288
|
+
const onetime = (function_, options = {}) => {
|
|
289
|
+
if (typeof function_ !== 'function') {
|
|
290
|
+
throw new TypeError('Expected a function');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
let returnValue;
|
|
294
|
+
let callCount = 0;
|
|
295
|
+
const functionName = function_.displayName || function_.name || '<anonymous>';
|
|
296
|
+
|
|
297
|
+
const onetime = function (...arguments_) {
|
|
298
|
+
calledFunctions.set(onetime, ++callCount);
|
|
299
|
+
|
|
300
|
+
if (callCount === 1) {
|
|
301
|
+
returnValue = function_.apply(this, arguments_);
|
|
302
|
+
function_ = null;
|
|
303
|
+
} else if (options.throw === true) {
|
|
304
|
+
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return returnValue;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
mimicFn(onetime, function_);
|
|
311
|
+
calledFunctions.set(onetime, callCount);
|
|
312
|
+
|
|
313
|
+
return onetime;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
onetime$2.exports = onetime;
|
|
317
|
+
// TODO: Remove this for the next major release
|
|
318
|
+
onetime$2.exports.default = onetime;
|
|
319
|
+
|
|
320
|
+
onetime$2.exports.callCount = function_ => {
|
|
321
|
+
if (!calledFunctions.has(function_)) {
|
|
322
|
+
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return calledFunctions.get(function_);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
var onetime$1 = onetime$2.exports;
|
|
329
|
+
|
|
330
330
|
export { signalExit$1 as a, onetime$2 as b, onetime$1 as o, signalExit as s };
|