vitest 0.0.110 → 0.0.114
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 +29 -0
- package/dist/cli.js +11 -9
- package/dist/{constants-e762cbc5.js → constants-9c7f06df.js} +2 -2
- package/dist/{diff-46ee5d7d.js → diff-3cfdad26.js} +3299 -3298
- package/dist/entry.js +79 -21
- package/dist/{global-b8ab5632.js → global-12653c72.js} +6 -6
- package/dist/{index-b183bb20.js → index-36694964.js} +888 -1768
- package/dist/index-7889832e.js +53 -0
- package/dist/{utils-d97bd6d9.js → index-ea5153a0.js} +13 -2
- package/dist/{index-a90f376d.js → index-ebf35a56.js} +2 -2
- package/dist/index.d.ts +152 -35
- package/dist/index.js +5 -4
- package/dist/{jest-mock-a57b745c.js → jest-mock-4a754991.js} +1 -12
- package/dist/magic-string.es-94000aea.js +1360 -0
- package/dist/{middleware-093a3bde.js → middleware-85ff8fbf.js} +2 -2
- package/dist/node.d.ts +72 -1
- package/dist/node.js +8 -6
- package/dist/{rpc-7de86f29.js → rpc-85fe6402.js} +4 -4
- package/dist/utils.js +3 -2
- package/dist/{vi-aedc8539.js → vi-67e478ef.js} +14 -3
- package/dist/worker.js +23 -35
- package/package.json +7 -6
package/dist/node.d.ts
CHANGED
|
@@ -1,7 +1,70 @@
|
|
|
1
1
|
import { ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
|
|
2
|
+
import { RawSourceMap } from 'source-map-js';
|
|
2
3
|
import { OptionsReceived } from 'pretty-format';
|
|
3
4
|
|
|
5
|
+
declare abstract class BaseReporter implements Reporter {
|
|
6
|
+
ctx: Vitest;
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
watchFilters?: string[];
|
|
10
|
+
isTTY: boolean;
|
|
11
|
+
constructor(ctx: Vitest);
|
|
12
|
+
relative(path: string): string;
|
|
13
|
+
onFinished(files?: File[]): Promise<void>;
|
|
14
|
+
onTaskUpdate(pack: TaskResultPack): void;
|
|
15
|
+
isFirstWatchRun: boolean;
|
|
16
|
+
onWatcherStart(): Promise<void>;
|
|
17
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
18
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
19
|
+
onServerRestart(): void;
|
|
20
|
+
reportSummary(files: File[]): Promise<void>;
|
|
21
|
+
private printTaskErrors;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ListRendererOptions {
|
|
25
|
+
renderSucceed?: boolean;
|
|
26
|
+
}
|
|
27
|
+
declare const createListRenderer: (_tasks: Task[], options?: ListRendererOptions) => {
|
|
28
|
+
start(): any;
|
|
29
|
+
update(_tasks: Task[]): any;
|
|
30
|
+
stop(): Promise<any>;
|
|
31
|
+
clear(): void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
declare class DefaultReporter extends BaseReporter {
|
|
35
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
36
|
+
rendererOptions: ListRendererOptions;
|
|
37
|
+
onStart(): void;
|
|
38
|
+
onFinished(files?: File[]): Promise<void>;
|
|
39
|
+
onWatcherStart(): Promise<void>;
|
|
40
|
+
stopListRender(): Promise<void>;
|
|
41
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
42
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare class DotReporter extends BaseReporter {
|
|
46
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
47
|
+
onStart(): void;
|
|
48
|
+
onFinished(files?: File[]): Promise<void>;
|
|
49
|
+
onWatcherStart(): Promise<void>;
|
|
50
|
+
stopListRender(): Promise<void>;
|
|
51
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
52
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
56
|
+
constructor(ctx: Vitest);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare const ReportersMap: {
|
|
60
|
+
default: typeof DefaultReporter;
|
|
61
|
+
verbose: typeof VerboseReporter;
|
|
62
|
+
dot: typeof DotReporter;
|
|
63
|
+
};
|
|
64
|
+
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
65
|
+
|
|
4
66
|
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
67
|
+
declare type Arrayable<T> = T | Array<T>;
|
|
5
68
|
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
6
69
|
interface UserConsoleLog {
|
|
7
70
|
content: string;
|
|
@@ -156,7 +219,7 @@ interface InlineConfig {
|
|
|
156
219
|
/**
|
|
157
220
|
* Custom reporter for output
|
|
158
221
|
*/
|
|
159
|
-
reporters?:
|
|
222
|
+
reporters?: Arrayable<BuiltinReporters | Reporter>;
|
|
160
223
|
/**
|
|
161
224
|
* Enable multi-threading
|
|
162
225
|
*
|
|
@@ -204,6 +267,12 @@ interface InlineConfig {
|
|
|
204
267
|
* @default ['**\/node_modules\/**', '**\/dist/**']
|
|
205
268
|
*/
|
|
206
269
|
watchIgnore?: (string | RegExp)[];
|
|
270
|
+
/**
|
|
271
|
+
* Isolate environment for each test file
|
|
272
|
+
*
|
|
273
|
+
* @default true
|
|
274
|
+
*/
|
|
275
|
+
isolate?: boolean;
|
|
207
276
|
/**
|
|
208
277
|
* Open Vitest UI
|
|
209
278
|
* @internal WIP
|
|
@@ -301,6 +370,7 @@ declare class Vitest {
|
|
|
301
370
|
pool: WorkerPool | undefined;
|
|
302
371
|
invalidates: Set<string>;
|
|
303
372
|
changedTests: Set<string>;
|
|
373
|
+
visitedFilesMap: Map<string, RawSourceMap>;
|
|
304
374
|
runningPromise?: Promise<void>;
|
|
305
375
|
isFirstRun: boolean;
|
|
306
376
|
restartsCount: number;
|
|
@@ -319,6 +389,7 @@ declare class Vitest {
|
|
|
319
389
|
close(): Promise<void>;
|
|
320
390
|
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
321
391
|
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
392
|
+
writeC8Sourcemap(): Promise<void>;
|
|
322
393
|
isTargetFile(id: string): boolean;
|
|
323
394
|
onServerRestarted(fn: () => void): void;
|
|
324
395
|
}
|
package/dist/node.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
2
|
-
import '
|
|
1
|
+
export { c as createVitest } from './index-36694964.js';
|
|
2
|
+
import 'fs';
|
|
3
|
+
import 'url';
|
|
4
|
+
import './index-ea5153a0.js';
|
|
3
5
|
import 'tty';
|
|
4
6
|
import 'local-pkg';
|
|
5
7
|
import 'path';
|
|
6
8
|
import 'vite';
|
|
7
9
|
import 'process';
|
|
8
|
-
import 'fs';
|
|
9
10
|
import 'os';
|
|
10
11
|
import 'util';
|
|
11
12
|
import 'stream';
|
|
12
13
|
import 'events';
|
|
13
|
-
import './constants-
|
|
14
|
-
import '
|
|
14
|
+
import './constants-9c7f06df.js';
|
|
15
|
+
import './magic-string.es-94000aea.js';
|
|
15
16
|
import 'perf_hooks';
|
|
16
|
-
import './diff-
|
|
17
|
+
import './diff-3cfdad26.js';
|
|
17
18
|
import './index-61c8686f.js';
|
|
18
19
|
import './_commonjsHelpers-c9e3b764.js';
|
|
19
20
|
import 'assert';
|
|
20
21
|
import 'worker_threads';
|
|
21
22
|
import 'tinypool';
|
|
23
|
+
import './index-7889832e.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const rpc =
|
|
1
|
+
const rpc = (method, ...args) => {
|
|
2
2
|
var _a;
|
|
3
|
-
return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc(method, ...args);
|
|
3
|
+
return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc.call(method, ...args);
|
|
4
4
|
};
|
|
5
|
-
const send =
|
|
5
|
+
const send = (method, ...args) => {
|
|
6
6
|
var _a;
|
|
7
|
-
return (_a = process.__vitest_worker__) == null ? void 0 : _a.send(method, ...args);
|
|
7
|
+
return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc.send(method, ...args);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export { rpc as r, send as s };
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { e as ensurePackageInstalled, g as getNames,
|
|
2
|
-
import '
|
|
1
|
+
export { e as ensurePackageInstalled, g as getFullName, q as getNames, a as getSuites, y as getTasks, f as getTests, h as hasFailed, w as hasTests, u as interpretOnlyMode, x as isWindows, o as mergeSlashes, n as noop, m as notNullish, v as partitionSuiteChildren, j as resolvePath, s as slash, k as toArray, t as toFilePath } from './index-ea5153a0.js';
|
|
2
|
+
import 'url';
|
|
3
3
|
import 'tty';
|
|
4
|
+
import 'local-pkg';
|
|
4
5
|
import 'path';
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { n as noop } from './utils-d97bd6d9.js';
|
|
1
|
+
import { n as noop } from './index-ea5153a0.js';
|
|
3
2
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-c9e3b764.js';
|
|
3
|
+
import { a as spyOn, f as fn, s as spies } from './jest-mock-4a754991.js';
|
|
4
|
+
|
|
5
|
+
let urlAlphabet =
|
|
6
|
+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
7
|
+
let nanoid = (size = 21) => {
|
|
8
|
+
let id = '';
|
|
9
|
+
let i = size;
|
|
10
|
+
while (i--) {
|
|
11
|
+
id += urlAlphabet[(Math.random() * 64) | 0];
|
|
12
|
+
}
|
|
13
|
+
return id
|
|
14
|
+
};
|
|
4
15
|
|
|
5
16
|
var __defProp = Object.defineProperty;
|
|
6
17
|
var __defProps = Object.defineProperties;
|
|
@@ -1015,4 +1026,4 @@ class VitestUtils {
|
|
|
1015
1026
|
const vitest = new VitestUtils();
|
|
1016
1027
|
const vi = vitest;
|
|
1017
1028
|
|
|
1018
|
-
export { JestChaiExpect as J, getDefaultHookTimeout as a, getState as b, suite as c, describe as d, vi as e, equals as f, getCurrentSuite as g, iterableEquality as h, it as i, subsetEquality as j, isA as k, clearContext as l, defaultSuite as m,
|
|
1029
|
+
export { JestChaiExpect as J, getDefaultHookTimeout as a, getState as b, suite as c, describe as d, vi as e, equals as f, getCurrentSuite as g, iterableEquality as h, it as i, subsetEquality as j, isA as k, clearContext as l, defaultSuite as m, nanoid as n, setHooks as o, getHooks as p, context as q, getFn as r, setState as s, test as t, vitest as v, withTimeout as w };
|
package/dist/worker.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { c as distDir } from './constants-
|
|
1
|
+
import { j as resolve, d as dirname$2, b as basename$2, o as mergeSlashes, s as slash, t as toFilePath } from './index-ea5153a0.js';
|
|
2
|
+
import { c as createBirpc } from './index-7889832e.js';
|
|
3
|
+
import { c as distDir } from './constants-9c7f06df.js';
|
|
4
4
|
import { builtinModules, createRequire } from 'module';
|
|
5
5
|
import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
|
|
6
6
|
import vm from 'vm';
|
|
7
7
|
import path from 'path';
|
|
8
|
-
import fs, { promises, realpathSync, statSync, Stats,
|
|
8
|
+
import fs, { promises, realpathSync, statSync, Stats, existsSync, readdirSync } from 'fs';
|
|
9
9
|
import assert from 'assert';
|
|
10
10
|
import { format as format$2, inspect } from 'util';
|
|
11
|
-
import { s as
|
|
11
|
+
import { a as spyOn, s as spies } from './jest-mock-4a754991.js';
|
|
12
|
+
import { s as send } from './rpc-85fe6402.js';
|
|
12
13
|
import 'tty';
|
|
13
14
|
import 'local-pkg';
|
|
14
15
|
import 'chai';
|
|
@@ -7663,7 +7664,7 @@ function find(dir) {
|
|
|
7663
7664
|
|
|
7664
7665
|
// Manually “tree shaken” from:
|
|
7665
7666
|
|
|
7666
|
-
const isWindows
|
|
7667
|
+
const isWindows = process.platform === 'win32';
|
|
7667
7668
|
|
|
7668
7669
|
const own$1 = {}.hasOwnProperty;
|
|
7669
7670
|
|
|
@@ -7837,7 +7838,7 @@ codes.ERR_UNSUPPORTED_ESM_URL_SCHEME = createError(
|
|
|
7837
7838
|
let message =
|
|
7838
7839
|
'Only file and data URLs are supported by the default ESM loader';
|
|
7839
7840
|
|
|
7840
|
-
if (isWindows
|
|
7841
|
+
if (isWindows && url.protocol.length === 2) {
|
|
7841
7842
|
message += '. On Windows, absolute paths must be valid file:// URLs';
|
|
7842
7843
|
}
|
|
7843
7844
|
|
|
@@ -9218,6 +9219,8 @@ var __spreadValues = (a, b) => {
|
|
|
9218
9219
|
function resolveMockPath(mockPath, root, nmName) {
|
|
9219
9220
|
if (nmName) {
|
|
9220
9221
|
const mockFolder = resolve(root, "__mocks__");
|
|
9222
|
+
if (!existsSync(mockFolder))
|
|
9223
|
+
return null;
|
|
9221
9224
|
const files = readdirSync(mockFolder);
|
|
9222
9225
|
for (const file of files) {
|
|
9223
9226
|
const [basename2] = file.split(".");
|
|
@@ -9325,7 +9328,6 @@ const depsExternal = [
|
|
|
9325
9328
|
/\.cjs.js$/,
|
|
9326
9329
|
/\.mjs$/
|
|
9327
9330
|
];
|
|
9328
|
-
const isWindows = process.platform === "win32";
|
|
9329
9331
|
const stubRequests = {
|
|
9330
9332
|
"/@vite/client": {
|
|
9331
9333
|
injectQuery: (id) => id,
|
|
@@ -9530,12 +9532,6 @@ async function shouldExternalize(id, config) {
|
|
|
9530
9532
|
return false;
|
|
9531
9533
|
return id.includes("/node_modules/") && await isValidNodeImport(id);
|
|
9532
9534
|
}
|
|
9533
|
-
function toFilePath(id, root) {
|
|
9534
|
-
let absolute = slash(id).startsWith("/@fs/") ? id.slice(4) : id.startsWith(dirname$2(root)) ? id : id.startsWith("/") ? slash(resolve(root, id.slice(1))) : id;
|
|
9535
|
-
if (absolute.startsWith("//"))
|
|
9536
|
-
absolute = absolute.slice(1);
|
|
9537
|
-
return isWindows && absolute.startsWith("/") ? fileURLToPath$2(pathToFileURL(absolute.slice(1)).href) : absolute;
|
|
9538
|
-
}
|
|
9539
9535
|
function matchExternalizePattern(id, patterns) {
|
|
9540
9536
|
for (const ex of patterns) {
|
|
9541
9537
|
if (typeof ex === "string") {
|
|
@@ -9578,7 +9574,7 @@ async function startViteNode(ctx) {
|
|
|
9578
9574
|
resolve(distDir, "entry.js")
|
|
9579
9575
|
],
|
|
9580
9576
|
fetch(id) {
|
|
9581
|
-
return process.__vitest_worker__.rpc("fetch", id);
|
|
9577
|
+
return process.__vitest_worker__.rpc.call("fetch", id);
|
|
9582
9578
|
},
|
|
9583
9579
|
inline: config.depsInline,
|
|
9584
9580
|
external: config.depsExternal,
|
|
@@ -9590,32 +9586,24 @@ async function startViteNode(ctx) {
|
|
|
9590
9586
|
return _viteNode;
|
|
9591
9587
|
}
|
|
9592
9588
|
function init(ctx) {
|
|
9589
|
+
if (process.__vitest_worker__ && ctx.config.threads)
|
|
9590
|
+
throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${process.__vitest_worker__.ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
|
|
9593
9591
|
process.stdout.write("\0");
|
|
9594
9592
|
const { config, port } = ctx;
|
|
9595
|
-
const rpcPromiseMap = /* @__PURE__ */ new Map();
|
|
9596
9593
|
process.__vitest_worker__ = {
|
|
9594
|
+
ctx,
|
|
9597
9595
|
moduleCache,
|
|
9598
9596
|
config,
|
|
9599
|
-
rpc: (
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
}
|
|
9597
|
+
rpc: createBirpc({
|
|
9598
|
+
functions: {},
|
|
9599
|
+
post(v) {
|
|
9600
|
+
port.postMessage(v);
|
|
9601
|
+
},
|
|
9602
|
+
on(fn) {
|
|
9603
|
+
port.addListener("message", fn);
|
|
9604
|
+
}
|
|
9605
|
+
})
|
|
9609
9606
|
};
|
|
9610
|
-
port.addListener("message", async (data) => {
|
|
9611
|
-
const api = rpcPromiseMap.get(data.id);
|
|
9612
|
-
if (api) {
|
|
9613
|
-
if (data.error)
|
|
9614
|
-
api.reject(data.error);
|
|
9615
|
-
else
|
|
9616
|
-
api.resolve(data.result);
|
|
9617
|
-
}
|
|
9618
|
-
});
|
|
9619
9607
|
if (ctx.invalidates)
|
|
9620
9608
|
ctx.invalidates.forEach((i) => moduleCache.delete(i));
|
|
9621
9609
|
ctx.files.forEach((i) => moduleCache.delete(i));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.114",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -51,17 +51,18 @@
|
|
|
51
51
|
"@types/chai-subset": "^1.3.3",
|
|
52
52
|
"chai": "^4.3.4",
|
|
53
53
|
"local-pkg": "^0.4.0",
|
|
54
|
-
"tinypool": "^0.0.
|
|
55
|
-
"tinyspy": "^0.2.
|
|
54
|
+
"tinypool": "^0.0.6",
|
|
55
|
+
"tinyspy": "^0.2.6"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@antfu/install-pkg": "^0.1.0",
|
|
59
|
-
"@types/diff": "^5.0.
|
|
59
|
+
"@types/diff": "^5.0.2",
|
|
60
60
|
"@types/jsdom": "^16.2.14",
|
|
61
61
|
"@types/micromatch": "^4.0.2",
|
|
62
62
|
"@types/natural-compare": "^1.4.1",
|
|
63
|
-
"@types/node": "^17.0.
|
|
63
|
+
"@types/node": "^17.0.4",
|
|
64
64
|
"@types/prompts": "^2.4.0",
|
|
65
|
+
"birpc": "^0.0.0",
|
|
65
66
|
"c8": "^7.10.0",
|
|
66
67
|
"cac": "^6.7.12",
|
|
67
68
|
"chai-subset": "^1.6.0",
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
"pkg-types": "^0.3.2",
|
|
85
86
|
"pretty-format": "^27.4.2",
|
|
86
87
|
"prompts": "^2.4.2",
|
|
87
|
-
"rollup": "^2.
|
|
88
|
+
"rollup": "^2.62.0",
|
|
88
89
|
"source-map-js": "^1.0.1",
|
|
89
90
|
"strip-ansi": "^7.0.1",
|
|
90
91
|
"typescript": "^4.5.4"
|