vitest 0.0.121 → 0.0.125
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 +2 -2
- package/README.md +1 -3
- package/dist/cli.js +12 -6
- package/dist/{constants-22bbd600.js → constants-8b3a9b31.js} +1 -1
- package/dist/{diff-a295cb37.js → diff-3adb959a.js} +34 -20
- package/dist/entry.js +40 -2349
- package/dist/externalize-2f63779d.js +9258 -0
- package/dist/{global-f5814404.js → global-3b7dd162.js} +4 -4
- package/dist/{index-123a18df.js → index-37193236.js} +65 -26
- package/dist/{index-32bc2073.js → index-7f52a6d6.js} +1 -1
- package/dist/{index-090545ef.js → index-9fdde2e8.js} +25 -27
- package/dist/index.d.ts +99 -62
- package/dist/index.js +3 -3
- package/dist/node.d.ts +47 -9
- package/dist/node.js +5 -5
- package/dist/{setup-c9c7cb5b.js → setup-b0d2ca33.js} +50 -4
- package/dist/vi-56df0b20.js +3443 -0
- package/dist/worker.js +25 -9242
- package/package.json +13 -8
- package/dist/utils.js +0 -5
- package/dist/vi-db2bc738.js +0 -1122
package/dist/node.d.ts
CHANGED
|
@@ -122,24 +122,44 @@ interface UserConsoleLog {
|
|
|
122
122
|
type: 'stdout' | 'stderr';
|
|
123
123
|
taskId?: string;
|
|
124
124
|
}
|
|
125
|
+
interface Position {
|
|
126
|
+
line: number;
|
|
127
|
+
column: number;
|
|
128
|
+
}
|
|
129
|
+
interface ParsedStack {
|
|
130
|
+
method: string;
|
|
131
|
+
file: string;
|
|
132
|
+
line: number;
|
|
133
|
+
column: number;
|
|
134
|
+
sourcePos?: Position;
|
|
135
|
+
}
|
|
136
|
+
interface ErrorWithDiff extends Error {
|
|
137
|
+
name: string;
|
|
138
|
+
nameStr?: string;
|
|
139
|
+
stack?: string;
|
|
140
|
+
stackStr?: string;
|
|
141
|
+
stacks?: ParsedStack[];
|
|
142
|
+
showDiff?: boolean;
|
|
143
|
+
actual?: any;
|
|
144
|
+
expected?: any;
|
|
145
|
+
operator?: string;
|
|
146
|
+
}
|
|
125
147
|
|
|
126
148
|
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
127
149
|
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
128
|
-
declare type ComputeMode = 'serial' | 'concurrent';
|
|
129
150
|
interface TaskBase {
|
|
130
151
|
id: string;
|
|
131
152
|
name: string;
|
|
132
153
|
mode: RunMode;
|
|
133
|
-
|
|
154
|
+
concurrent?: boolean;
|
|
134
155
|
suite?: Suite;
|
|
135
156
|
file?: File;
|
|
136
157
|
result?: TaskResult;
|
|
137
158
|
}
|
|
138
159
|
interface TaskResult {
|
|
139
160
|
state: TaskState;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
error?: unknown;
|
|
161
|
+
duration?: number;
|
|
162
|
+
error?: ErrorWithDiff;
|
|
143
163
|
}
|
|
144
164
|
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
145
165
|
interface Suite extends TaskBase {
|
|
@@ -148,6 +168,7 @@ interface Suite extends TaskBase {
|
|
|
148
168
|
}
|
|
149
169
|
interface File extends Suite {
|
|
150
170
|
filepath: string;
|
|
171
|
+
collectDuration?: number;
|
|
151
172
|
}
|
|
152
173
|
interface Test extends TaskBase {
|
|
153
174
|
type: 'test';
|
|
@@ -237,6 +258,20 @@ interface InlineConfig {
|
|
|
237
258
|
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
238
259
|
*/
|
|
239
260
|
inline?: (string | RegExp)[];
|
|
261
|
+
/**
|
|
262
|
+
* Interpret CJS module's default as named exports
|
|
263
|
+
*
|
|
264
|
+
* @default true
|
|
265
|
+
*/
|
|
266
|
+
interpretDefault?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* When a dependency is a valid ESM package, try to guess the cjs version based on the path.
|
|
269
|
+
* This will significantly improve the performance in huge repo, but might potentially
|
|
270
|
+
* cause some misalignment if a package have different logic in ESM and CJS mode.
|
|
271
|
+
*
|
|
272
|
+
* @default true
|
|
273
|
+
*/
|
|
274
|
+
fallbackCJS?: boolean;
|
|
240
275
|
};
|
|
241
276
|
/**
|
|
242
277
|
* Register apis globally
|
|
@@ -290,7 +325,6 @@ interface InlineConfig {
|
|
|
290
325
|
* @default available CPUs
|
|
291
326
|
*/
|
|
292
327
|
minThreads?: number;
|
|
293
|
-
interpretDefault?: boolean;
|
|
294
328
|
/**
|
|
295
329
|
* Default timeout of a test in milliseconds
|
|
296
330
|
*
|
|
@@ -389,15 +423,17 @@ interface UserConfig extends InlineConfig {
|
|
|
389
423
|
/**
|
|
390
424
|
* Run tests that cover a list of source files
|
|
391
425
|
*/
|
|
392
|
-
|
|
426
|
+
related?: string[] | string;
|
|
393
427
|
}
|
|
394
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | '
|
|
428
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related'> {
|
|
395
429
|
config?: string;
|
|
396
430
|
filters?: string[];
|
|
397
431
|
testNamePattern?: RegExp;
|
|
398
|
-
|
|
432
|
+
related?: string[];
|
|
399
433
|
depsInline: (string | RegExp)[];
|
|
400
434
|
depsExternal: (string | RegExp)[];
|
|
435
|
+
fallbackCJS: boolean;
|
|
436
|
+
interpretDefault: boolean;
|
|
401
437
|
coverage: ResolvedC8Options;
|
|
402
438
|
snapshotOptions: SnapshotStateOptions;
|
|
403
439
|
}
|
|
@@ -452,6 +488,8 @@ declare class Vitest {
|
|
|
452
488
|
constructor();
|
|
453
489
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
454
490
|
start(filters?: string[]): Promise<void>;
|
|
491
|
+
private getTestDependencies;
|
|
492
|
+
filterTestsBySource(tests: string[]): Promise<string[]>;
|
|
455
493
|
runFiles(files: string[]): Promise<void>;
|
|
456
494
|
log(...args: any[]): void;
|
|
457
495
|
error(...args: any[]): void;
|
package/dist/node.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
2
|
-
import '
|
|
1
|
+
export { c as createVitest } from './index-37193236.js';
|
|
2
|
+
import 'fs';
|
|
3
|
+
import './index-9fdde2e8.js';
|
|
3
4
|
import 'url';
|
|
4
5
|
import 'tty';
|
|
5
6
|
import 'local-pkg';
|
|
6
7
|
import 'path';
|
|
7
8
|
import 'vite';
|
|
8
9
|
import 'process';
|
|
9
|
-
import 'fs';
|
|
10
10
|
import 'os';
|
|
11
11
|
import 'util';
|
|
12
12
|
import 'stream';
|
|
13
13
|
import 'events';
|
|
14
|
-
import './constants-
|
|
14
|
+
import './constants-8b3a9b31.js';
|
|
15
15
|
import './magic-string.es-94000aea.js';
|
|
16
16
|
import 'perf_hooks';
|
|
17
|
-
import './diff-
|
|
17
|
+
import './diff-3adb959a.js';
|
|
18
18
|
import './index-648e7ab2.js';
|
|
19
19
|
import './_commonjsHelpers-c9e3b764.js';
|
|
20
20
|
import 'assert';
|
|
@@ -9,11 +9,16 @@ import require$$2 from 'events';
|
|
|
9
9
|
import require$$1 from 'https';
|
|
10
10
|
import require$$2$1 from 'http';
|
|
11
11
|
import require$$7 from 'url';
|
|
12
|
-
import { A as API_PATH } from './constants-
|
|
13
|
-
import './
|
|
12
|
+
import { A as API_PATH } from './constants-8b3a9b31.js';
|
|
13
|
+
import { s as shouldExternalize } from './externalize-2f63779d.js';
|
|
14
|
+
import { o as interpretSourcePos, n as parseStacktrace } from './diff-3adb959a.js';
|
|
15
|
+
import './index-9fdde2e8.js';
|
|
14
16
|
import 'tty';
|
|
15
17
|
import 'local-pkg';
|
|
16
18
|
import 'path';
|
|
19
|
+
import 'module';
|
|
20
|
+
import 'assert';
|
|
21
|
+
import 'util';
|
|
17
22
|
|
|
18
23
|
/*! (c) 2020 Andrea Giammarchi */
|
|
19
24
|
|
|
@@ -4266,9 +4271,12 @@ function setup(ctx) {
|
|
|
4266
4271
|
getFiles() {
|
|
4267
4272
|
return ctx.state.getFiles();
|
|
4268
4273
|
},
|
|
4269
|
-
|
|
4274
|
+
readFile(id) {
|
|
4270
4275
|
return promises.readFile(id, "utf-8");
|
|
4271
4276
|
},
|
|
4277
|
+
writeFile(id, content) {
|
|
4278
|
+
return promises.writeFile(id, content, "utf-8");
|
|
4279
|
+
},
|
|
4272
4280
|
async rerun(files) {
|
|
4273
4281
|
await ctx.report("onWatcherRerun", files);
|
|
4274
4282
|
await ctx.runFiles(files);
|
|
@@ -4276,6 +4284,35 @@ function setup(ctx) {
|
|
|
4276
4284
|
},
|
|
4277
4285
|
getConfig() {
|
|
4278
4286
|
return ctx.config;
|
|
4287
|
+
},
|
|
4288
|
+
async getModuleGraph(id) {
|
|
4289
|
+
const graph = {};
|
|
4290
|
+
function clearId(id2) {
|
|
4291
|
+
return (id2 == null ? void 0 : id2.replace(/\?v=\w+$/, "")) || "";
|
|
4292
|
+
}
|
|
4293
|
+
function get(mod, seen = new Set()) {
|
|
4294
|
+
if (!mod || !mod.id || seen.has(mod))
|
|
4295
|
+
return;
|
|
4296
|
+
seen.add(mod);
|
|
4297
|
+
const mods = Array.from(mod.importedModules).filter((i) => i.id && !i.id.includes("/vitest/dist/"));
|
|
4298
|
+
graph[clearId(mod.id)] = mods.map((i) => clearId(i.id));
|
|
4299
|
+
mods.forEach((m) => get(m, seen));
|
|
4300
|
+
}
|
|
4301
|
+
get(ctx.server.moduleGraph.getModuleById(id));
|
|
4302
|
+
const externalized = [];
|
|
4303
|
+
const inlined = [];
|
|
4304
|
+
await Promise.all(Object.keys(graph).map(async (i) => {
|
|
4305
|
+
const rewrote = await shouldExternalize(i, ctx.config);
|
|
4306
|
+
if (rewrote)
|
|
4307
|
+
externalized.push(rewrote);
|
|
4308
|
+
else
|
|
4309
|
+
inlined.push(i);
|
|
4310
|
+
}));
|
|
4311
|
+
return {
|
|
4312
|
+
graph,
|
|
4313
|
+
externalized,
|
|
4314
|
+
inlined
|
|
4315
|
+
};
|
|
4279
4316
|
}
|
|
4280
4317
|
},
|
|
4281
4318
|
post(msg) {
|
|
@@ -4302,12 +4339,21 @@ class WebSocketReporter {
|
|
|
4302
4339
|
this.clients = clients;
|
|
4303
4340
|
}
|
|
4304
4341
|
onCollected(files) {
|
|
4342
|
+
if (this.clients.size === 0)
|
|
4343
|
+
return;
|
|
4305
4344
|
this.clients.forEach((client) => {
|
|
4306
4345
|
var _a;
|
|
4307
4346
|
(_a = client.onCollected) == null ? void 0 : _a.call(client, files);
|
|
4308
4347
|
});
|
|
4309
4348
|
}
|
|
4310
|
-
onTaskUpdate(packs) {
|
|
4349
|
+
async onTaskUpdate(packs) {
|
|
4350
|
+
if (this.clients.size === 0)
|
|
4351
|
+
return;
|
|
4352
|
+
await Promise.all(packs.map(async (i) => {
|
|
4353
|
+
var _a;
|
|
4354
|
+
if ((_a = i[1]) == null ? void 0 : _a.error)
|
|
4355
|
+
await interpretSourcePos(parseStacktrace(i[1].error), this.ctx);
|
|
4356
|
+
}));
|
|
4311
4357
|
this.clients.forEach((client) => {
|
|
4312
4358
|
var _a;
|
|
4313
4359
|
(_a = client.onTaskUpdate) == null ? void 0 : _a.call(client, packs);
|