vitest 0.0.119 → 0.0.123
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/dist/cli.js +6 -6
- package/dist/{constants-22bbd600.js → constants-744cb76d.js} +1 -1
- package/dist/{diff-a295cb37.js → diff-a0cbb825.js} +1 -1
- package/dist/entry.js +75 -2367
- package/dist/externalize-2f63779d.js +9258 -0
- package/dist/{global-8f03a13e.js → global-f9288768.js} +5 -5
- package/dist/{index-090545ef.js → index-250bdca0.js} +2 -5
- package/dist/{index-31a38185.js → index-68c0c743.js} +2 -2
- package/dist/{index-478354a1.js → index-a7ae9662.js} +35 -25
- package/dist/index.d.ts +63 -23
- package/dist/index.js +4 -4
- package/dist/{jest-mock-4a754991.js → jest-mock-038a01b3.js} +1 -1
- package/dist/node.d.ts +25 -6
- package/dist/node.js +4 -4
- package/dist/{setup-638014f2.js → setup-647e44ef.js} +36 -3
- package/dist/vi-aef0a94d.js +3443 -0
- package/dist/worker.js +44 -9256
- package/package.json +9 -4
- package/dist/utils.js +0 -5
- package/dist/vi-092f86e3.js +0 -1042
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-744cb76d.js';
|
|
2
|
+
import { i as index } from './index-68c0c743.js';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './index-
|
|
4
|
+
import './index-250bdca0.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './vi-
|
|
8
|
+
import './vi-aef0a94d.js';
|
|
9
9
|
import './_commonjsHelpers-c9e3b764.js';
|
|
10
|
-
import './jest-mock-
|
|
10
|
+
import './jest-mock-038a01b3.js';
|
|
11
11
|
import 'chai';
|
|
12
12
|
import 'tinyspy';
|
|
13
13
|
|
|
@@ -271,7 +271,7 @@ function partitionSuiteChildren(suite) {
|
|
|
271
271
|
let tasksGroup = [];
|
|
272
272
|
const tasksGroups = [];
|
|
273
273
|
for (const c2 of suite.tasks) {
|
|
274
|
-
if (tasksGroup.length === 0 || c2.
|
|
274
|
+
if (tasksGroup.length === 0 || c2.concurrent === tasksGroup[0].concurrent) {
|
|
275
275
|
tasksGroup.push(c2);
|
|
276
276
|
} else {
|
|
277
277
|
tasksGroups.push(tasksGroup);
|
|
@@ -285,9 +285,6 @@ function partitionSuiteChildren(suite) {
|
|
|
285
285
|
function getTests(suite) {
|
|
286
286
|
return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
|
|
287
287
|
}
|
|
288
|
-
function getTasks(tasks) {
|
|
289
|
-
return toArray(tasks).flatMap((s) => s.type === "test" ? [s] : [s, ...getTasks(s.tasks)]);
|
|
290
|
-
}
|
|
291
288
|
function getSuites(suite) {
|
|
292
289
|
return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
|
|
293
290
|
}
|
|
@@ -365,4 +362,4 @@ function toFilePath(id, root) {
|
|
|
365
362
|
return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
|
|
366
363
|
}
|
|
367
364
|
|
|
368
|
-
export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, join as q, relative as r, slash as s, toArray as t, index as u, getNames as v, partitionSuiteChildren as w, hasTests as x
|
|
365
|
+
export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, join as q, relative as r, slash as s, toArray as t, index as u, getNames as v, partitionSuiteChildren as w, hasTests as x };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-aef0a94d.js';
|
|
2
2
|
import chai, { assert, should } from 'chai';
|
|
3
|
-
import { s as spies, a as spyOn, f as fn } from './jest-mock-
|
|
3
|
+
import { s as spies, a as spyOn, f as fn } from './jest-mock-038a01b3.js';
|
|
4
4
|
|
|
5
5
|
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
6
6
|
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-
|
|
1
|
+
import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1, e as ensurePackageInstalled } from './index-250bdca0.js';
|
|
2
2
|
import { createServer, mergeConfig } from 'vite';
|
|
3
3
|
import path$a from 'path';
|
|
4
4
|
import process$1 from 'process';
|
|
@@ -7,10 +7,10 @@ import require$$0 from 'os';
|
|
|
7
7
|
import require$$0$1 from 'util';
|
|
8
8
|
import require$$0$2 from 'stream';
|
|
9
9
|
import require$$2 from 'events';
|
|
10
|
-
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-
|
|
10
|
+
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-744cb76d.js';
|
|
11
11
|
import MagicString from './magic-string.es-94000aea.js';
|
|
12
12
|
import { performance } from 'perf_hooks';
|
|
13
|
-
import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-
|
|
13
|
+
import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-a0cbb825.js';
|
|
14
14
|
import { o as onetime, s as signalExit } from './index-648e7ab2.js';
|
|
15
15
|
import { createRequire } from 'module';
|
|
16
16
|
import { pathToFileURL } from 'url';
|
|
@@ -6840,14 +6840,14 @@ const MocksPlugin = () => {
|
|
|
6840
6840
|
if (m) {
|
|
6841
6841
|
return {
|
|
6842
6842
|
code: m.toString(),
|
|
6843
|
-
map: m.generateMap()
|
|
6843
|
+
map: m.generateMap({ hires: true })
|
|
6844
6844
|
};
|
|
6845
6845
|
}
|
|
6846
6846
|
}
|
|
6847
6847
|
};
|
|
6848
6848
|
};
|
|
6849
6849
|
|
|
6850
|
-
const spinnerMap =
|
|
6850
|
+
const spinnerMap = new WeakMap();
|
|
6851
6851
|
const pointer = c.yellow(F_POINTER);
|
|
6852
6852
|
const skipped = c.dim(c.gray(F_DOWN));
|
|
6853
6853
|
function getCols(delta = 0) {
|
|
@@ -7058,9 +7058,9 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
|
|
|
7058
7058
|
await this.printTaskErrors(failedTests, errorDivider);
|
|
7059
7059
|
}
|
|
7060
7060
|
const executionTime = this.end - this.start;
|
|
7061
|
-
const threadTime =
|
|
7061
|
+
const threadTime = files.reduce((acc, test) => {
|
|
7062
7062
|
var _a;
|
|
7063
|
-
return acc + (((_a = test.result) == null ? void 0 : _a.
|
|
7063
|
+
return acc + (((_a = test.result) == null ? void 0 : _a.duration) || 0) + (test.collectDuration || 0);
|
|
7064
7064
|
}, 0);
|
|
7065
7065
|
const padTitle = (str) => c.dim(`${str.padStart(10)} `);
|
|
7066
7066
|
const time = (time2) => {
|
|
@@ -7598,7 +7598,7 @@ createLogUpdate(process$1.stderr);
|
|
|
7598
7598
|
|
|
7599
7599
|
const DURATION_LONG = 300;
|
|
7600
7600
|
const MAX_HEIGHT = 20;
|
|
7601
|
-
const outputMap =
|
|
7601
|
+
const outputMap = new WeakMap();
|
|
7602
7602
|
function formatFilepath(path) {
|
|
7603
7603
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
7604
7604
|
const basename = path.slice(lastSlash);
|
|
@@ -7618,10 +7618,9 @@ function renderTree(tasks, options, level = 0) {
|
|
|
7618
7618
|
suffix += c.dim(` (${getTests(task).length})`);
|
|
7619
7619
|
if (task.mode === "skip" || task.mode === "todo")
|
|
7620
7620
|
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
7621
|
-
if ((_a = task.result) == null ? void 0 : _a.
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
suffix += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
|
|
7621
|
+
if (((_a = task.result) == null ? void 0 : _a.duration) != null) {
|
|
7622
|
+
if (task.result.duration > DURATION_LONG)
|
|
7623
|
+
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
7625
7624
|
}
|
|
7626
7625
|
let name = task.name;
|
|
7627
7626
|
if (level === 0)
|
|
@@ -7893,9 +7892,9 @@ async function reportCoverage(ctx) {
|
|
|
7893
7892
|
|
|
7894
7893
|
class StateManager {
|
|
7895
7894
|
constructor() {
|
|
7896
|
-
this.filesMap =
|
|
7897
|
-
this.idMap =
|
|
7898
|
-
this.taskFileMap =
|
|
7895
|
+
this.filesMap = new Map();
|
|
7896
|
+
this.idMap = new Map();
|
|
7897
|
+
this.taskFileMap = new WeakMap();
|
|
7899
7898
|
}
|
|
7900
7899
|
getFiles(keys) {
|
|
7901
7900
|
if (keys)
|
|
@@ -7946,7 +7945,7 @@ var __spreadValues = (a, b) => {
|
|
|
7946
7945
|
};
|
|
7947
7946
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7948
7947
|
function resolveConfig(options, viteConfig) {
|
|
7949
|
-
var _a, _b;
|
|
7948
|
+
var _a, _b, _c, _d;
|
|
7950
7949
|
if (options.dom)
|
|
7951
7950
|
options.environment = "happy-dom";
|
|
7952
7951
|
const resolved = __spreadProps(__spreadValues({}, deepMerge(options, viteConfig.test)), {
|
|
@@ -7955,9 +7954,10 @@ function resolveConfig(options, viteConfig) {
|
|
|
7955
7954
|
resolved.coverage = resolveC8Options(resolved.coverage, resolved.root);
|
|
7956
7955
|
resolved.depsInline = [...((_a = resolved.deps) == null ? void 0 : _a.inline) || []];
|
|
7957
7956
|
resolved.depsExternal = [...((_b = resolved.deps) == null ? void 0 : _b.external) || []];
|
|
7957
|
+
resolved.fallbackCJS = ((_c = resolved.deps) == null ? void 0 : _c.fallbackCJS) ?? true;
|
|
7958
|
+
resolved.interpretDefault = ((_d = resolved.deps) == null ? void 0 : _d.interpretDefault) ?? true;
|
|
7958
7959
|
resolved.environment = resolved.environment || "node";
|
|
7959
7960
|
resolved.threads = resolved.threads ?? true;
|
|
7960
|
-
resolved.interpretDefault = resolved.interpretDefault ?? true;
|
|
7961
7961
|
resolved.clearMocks = resolved.clearMocks ?? false;
|
|
7962
7962
|
resolved.restoreMocks = resolved.restoreMocks ?? false;
|
|
7963
7963
|
resolved.mockReset = resolved.mockReset ?? false;
|
|
@@ -7980,10 +7980,12 @@ function resolveConfig(options, viteConfig) {
|
|
|
7980
7980
|
resolved.setupFiles = Array.from(resolved.setupFiles || []).map((i) => resolve(resolved.root, i));
|
|
7981
7981
|
if (resolved.api === true)
|
|
7982
7982
|
resolved.api = defaultPort;
|
|
7983
|
+
if (options.findRelatedTests)
|
|
7984
|
+
resolved.findRelatedTests = toArray(options.findRelatedTests).map((file) => resolve(resolved.root, file));
|
|
7983
7985
|
return resolved;
|
|
7984
7986
|
}
|
|
7985
7987
|
|
|
7986
|
-
const promiseMap =
|
|
7988
|
+
const promiseMap = new Map();
|
|
7987
7989
|
async function transformRequest(ctx, id) {
|
|
7988
7990
|
if (!promiseMap.has(id)) {
|
|
7989
7991
|
promiseMap.set(id, _transformRequest(ctx, id).then((r) => {
|
|
@@ -8145,9 +8147,9 @@ class Vitest {
|
|
|
8145
8147
|
this.reporters = void 0;
|
|
8146
8148
|
this.outputStream = process.stdout;
|
|
8147
8149
|
this.errorStream = process.stderr;
|
|
8148
|
-
this.invalidates =
|
|
8149
|
-
this.changedTests =
|
|
8150
|
-
this.visitedFilesMap =
|
|
8150
|
+
this.invalidates = new Set();
|
|
8151
|
+
this.changedTests = new Set();
|
|
8152
|
+
this.visitedFilesMap = new Map();
|
|
8151
8153
|
this.isFirstRun = true;
|
|
8152
8154
|
this.restartsCount = 0;
|
|
8153
8155
|
this._onRestartListeners = [];
|
|
@@ -8343,6 +8345,12 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8343
8345
|
const root = resolve(options.root || process.cwd());
|
|
8344
8346
|
const configPath = options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
8345
8347
|
let haveStarted = false;
|
|
8348
|
+
async function UIPlugin() {
|
|
8349
|
+
if (!options.open)
|
|
8350
|
+
return;
|
|
8351
|
+
await ensurePackageInstalled("@vitest/ui");
|
|
8352
|
+
return (await import('@vitest/ui')).default();
|
|
8353
|
+
}
|
|
8346
8354
|
const config = {
|
|
8347
8355
|
root,
|
|
8348
8356
|
logLevel: "error",
|
|
@@ -8357,14 +8365,16 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8357
8365
|
await ctx.setServer(options, server2);
|
|
8358
8366
|
haveStarted = true;
|
|
8359
8367
|
if (options.api)
|
|
8360
|
-
(await import('./setup-
|
|
8368
|
+
(await import('./setup-647e44ef.js')).setup(ctx);
|
|
8361
8369
|
}
|
|
8362
8370
|
},
|
|
8363
|
-
MocksPlugin()
|
|
8371
|
+
MocksPlugin(),
|
|
8372
|
+
await UIPlugin()
|
|
8364
8373
|
],
|
|
8365
8374
|
server: {
|
|
8366
|
-
open: options.open,
|
|
8367
|
-
strictPort: true
|
|
8375
|
+
open: options.open ? "/__vitest__/" : void 0,
|
|
8376
|
+
strictPort: true,
|
|
8377
|
+
preTransformRequests: false
|
|
8368
8378
|
},
|
|
8369
8379
|
build: {
|
|
8370
8380
|
sourcemap: true
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { OptionsReceived, Plugin } from 'pretty-format';
|
|
1
2
|
import { Formatter } from 'picocolors/types';
|
|
2
3
|
import { ViteDevServer } from 'vite';
|
|
3
4
|
import { RawSourceMap } from 'source-map-js';
|
|
4
|
-
import { OptionsReceived } from 'pretty-format';
|
|
5
5
|
import { MessagePort } from 'worker_threads';
|
|
6
|
+
import { SpyImpl } from 'tinyspy';
|
|
6
7
|
export { Spy, SpyFn } from 'tinyspy';
|
|
7
8
|
export { assert, default as chai, should } from 'chai';
|
|
8
9
|
|
|
@@ -85,9 +86,9 @@ declare type MatcherState = {
|
|
|
85
86
|
equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
|
|
86
87
|
expand?: boolean;
|
|
87
88
|
expectedAssertionsNumber?: number | null;
|
|
88
|
-
expectedAssertionsNumberError?: Error;
|
|
89
|
+
expectedAssertionsNumberError?: Error | null;
|
|
89
90
|
isExpectingAssertions?: boolean;
|
|
90
|
-
isExpectingAssertionsError?: Error;
|
|
91
|
+
isExpectingAssertionsError?: Error | null;
|
|
91
92
|
isNot: boolean;
|
|
92
93
|
promise: string;
|
|
93
94
|
suppressedErrors: Array<Error>;
|
|
@@ -378,20 +379,18 @@ declare type ChainableFunction<T extends string, Args extends any[], R = any> =
|
|
|
378
379
|
|
|
379
380
|
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
380
381
|
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
381
|
-
declare type ComputeMode = 'serial' | 'concurrent';
|
|
382
382
|
interface TaskBase {
|
|
383
383
|
id: string;
|
|
384
384
|
name: string;
|
|
385
385
|
mode: RunMode;
|
|
386
|
-
|
|
386
|
+
concurrent?: boolean;
|
|
387
387
|
suite?: Suite;
|
|
388
388
|
file?: File;
|
|
389
389
|
result?: TaskResult;
|
|
390
390
|
}
|
|
391
391
|
interface TaskResult {
|
|
392
392
|
state: TaskState;
|
|
393
|
-
|
|
394
|
-
end?: number;
|
|
393
|
+
duration?: number;
|
|
395
394
|
error?: unknown;
|
|
396
395
|
}
|
|
397
396
|
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
@@ -401,6 +400,7 @@ interface Suite extends TaskBase {
|
|
|
401
400
|
}
|
|
402
401
|
interface File extends Suite {
|
|
403
402
|
filepath: string;
|
|
403
|
+
collectDuration?: number;
|
|
404
404
|
}
|
|
405
405
|
interface Test extends TaskBase {
|
|
406
406
|
type: 'test';
|
|
@@ -528,6 +528,20 @@ interface InlineConfig {
|
|
|
528
528
|
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
529
529
|
*/
|
|
530
530
|
inline?: (string | RegExp)[];
|
|
531
|
+
/**
|
|
532
|
+
* Interpret CJS module's default as named exports
|
|
533
|
+
*
|
|
534
|
+
* @default true
|
|
535
|
+
*/
|
|
536
|
+
interpretDefault?: boolean;
|
|
537
|
+
/**
|
|
538
|
+
* When a dependency is a valid ESM package, try to guess the cjs version based on the path.
|
|
539
|
+
* This will significantly improve the performance in huge repo, but might potentially
|
|
540
|
+
* cause some misalignment if a package have different logic in ESM and CJS mode.
|
|
541
|
+
*
|
|
542
|
+
* @default true
|
|
543
|
+
*/
|
|
544
|
+
fallbackCJS?: boolean;
|
|
531
545
|
};
|
|
532
546
|
/**
|
|
533
547
|
* Register apis globally
|
|
@@ -581,7 +595,6 @@ interface InlineConfig {
|
|
|
581
595
|
* @default available CPUs
|
|
582
596
|
*/
|
|
583
597
|
minThreads?: number;
|
|
584
|
-
interpretDefault?: boolean;
|
|
585
598
|
/**
|
|
586
599
|
* Default timeout of a test in milliseconds
|
|
587
600
|
*
|
|
@@ -677,13 +690,20 @@ interface UserConfig extends InlineConfig {
|
|
|
677
690
|
* Pass with no tests
|
|
678
691
|
*/
|
|
679
692
|
passWithNoTests?: boolean;
|
|
693
|
+
/**
|
|
694
|
+
* Run tests that cover a list of source files
|
|
695
|
+
*/
|
|
696
|
+
findRelatedTests?: string[] | string;
|
|
680
697
|
}
|
|
681
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern'> {
|
|
698
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'findRelatedTests'> {
|
|
682
699
|
config?: string;
|
|
683
700
|
filters?: string[];
|
|
684
701
|
testNamePattern?: RegExp;
|
|
702
|
+
findRelatedTests?: string[];
|
|
685
703
|
depsInline: (string | RegExp)[];
|
|
686
704
|
depsExternal: (string | RegExp)[];
|
|
705
|
+
fallbackCJS: boolean;
|
|
706
|
+
interpretDefault: boolean;
|
|
687
707
|
coverage: ResolvedC8Options;
|
|
688
708
|
snapshotOptions: SnapshotStateOptions;
|
|
689
709
|
}
|
|
@@ -704,9 +724,9 @@ interface WorkerRPC {
|
|
|
704
724
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
705
725
|
}
|
|
706
726
|
|
|
707
|
-
declare const suite: ChainableFunction<"
|
|
727
|
+
declare const suite: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
|
|
708
728
|
declare const test: TestCollector;
|
|
709
|
-
declare const describe: ChainableFunction<"
|
|
729
|
+
declare const describe: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
|
|
710
730
|
declare const it: TestCollector;
|
|
711
731
|
|
|
712
732
|
declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number | undefined) => void;
|
|
@@ -782,6 +802,7 @@ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
|
782
802
|
};
|
|
783
803
|
declare type MaybeMockedDeep<T> = T extends MockableFunction ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
784
804
|
declare type MaybeMocked<T> = T extends MockableFunction ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
805
|
+
declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = JestMockCompat<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
|
|
785
806
|
interface MockWithArgs<T extends MockableFunction> extends JestMockCompatFn<ArgumentsOf<T>, ReturnType<T>> {
|
|
786
807
|
new (...args: ConstructorArgumentsOf<T>): T;
|
|
787
808
|
(...args: ArgumentsOf<T>): ReturnType<T>;
|
|
@@ -876,6 +897,11 @@ interface WebSocketHandlers {
|
|
|
876
897
|
getFiles(): File[];
|
|
877
898
|
getConfig(): ResolvedConfig;
|
|
878
899
|
getSourceCode(id: string): Promise<string>;
|
|
900
|
+
getModuleGraph(id: string): Promise<{
|
|
901
|
+
graph: Record<string, string[]>;
|
|
902
|
+
externalized: string[];
|
|
903
|
+
inlined: string[];
|
|
904
|
+
}>;
|
|
879
905
|
rerun(files: string[]): Promise<void>;
|
|
880
906
|
}
|
|
881
907
|
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onTaskUpdate'> {
|
|
@@ -891,23 +917,29 @@ declare module 'vite' {
|
|
|
891
917
|
test?: VitestInlineConfig;
|
|
892
918
|
}
|
|
893
919
|
}
|
|
920
|
+
interface AsymmetricMatchersContaining {
|
|
921
|
+
stringContaining(expected: string): void;
|
|
922
|
+
objectContaining(expected: any): ObjectContaining;
|
|
923
|
+
arrayContaining(expected: unknown[]): ArrayContaining;
|
|
924
|
+
stringMatching(expected: string | RegExp): StringMatching;
|
|
925
|
+
}
|
|
894
926
|
declare global {
|
|
895
927
|
namespace Chai {
|
|
896
|
-
interface ExpectStatic {
|
|
928
|
+
interface ExpectStatic extends AsymmetricMatchersContaining {
|
|
897
929
|
extend(expects: MatchersObject): void;
|
|
898
|
-
|
|
930
|
+
assertions(expected: number): void;
|
|
931
|
+
hasAssertions(): void;
|
|
899
932
|
anything(): Anything;
|
|
900
|
-
objectContaining(expected: any): ObjectContaining;
|
|
901
933
|
any(constructor: unknown): Any;
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
assertions(expected: number): void;
|
|
934
|
+
addSnapshotSerializer(plugin: Plugin): void;
|
|
935
|
+
not: AsymmetricMatchersContaining;
|
|
905
936
|
}
|
|
906
|
-
interface
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
937
|
+
interface JestAssertions {
|
|
938
|
+
toMatchSnapshot(message?: string): void;
|
|
939
|
+
toMatchInlineSnapshot(snapshot?: string, message?: string): void;
|
|
940
|
+
toThrowErrorMatchingSnapshot(message?: string): void;
|
|
941
|
+
toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
|
|
942
|
+
matchSnapshot(message?: string): void;
|
|
911
943
|
toEqual(expected: any): void;
|
|
912
944
|
toStrictEqual(expected: any): void;
|
|
913
945
|
toBe(expected: any): void;
|
|
@@ -953,7 +985,15 @@ declare global {
|
|
|
953
985
|
toHaveNthReturnedWith(nthCall: number, value: any): void;
|
|
954
986
|
nthReturnedWith(nthCall: number, value: any): void;
|
|
955
987
|
}
|
|
988
|
+
type Promisify<O> = {
|
|
989
|
+
[K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
|
|
990
|
+
};
|
|
991
|
+
interface Assertion extends JestAssertions {
|
|
992
|
+
resolves: Promisify<Assertion>;
|
|
993
|
+
rejects: Promisify<Assertion>;
|
|
994
|
+
chaiEqual(expected: any): void;
|
|
995
|
+
}
|
|
956
996
|
}
|
|
957
997
|
}
|
|
958
998
|
|
|
959
|
-
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment,
|
|
999
|
+
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ConstructorArgumentsOf, DoneCallback, EnhancedSpy, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, it, spies, spyOn, suite, test, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-
|
|
3
|
-
export { f as fn, s as spies, a as spyOn } from './jest-mock-
|
|
1
|
+
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-aef0a94d.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-68c0c743.js';
|
|
3
|
+
export { f as fn, s as spies, a as spyOn } from './jest-mock-038a01b3.js';
|
|
4
4
|
export { assert, default as chai, should } from 'chai';
|
|
5
|
-
import './index-
|
|
5
|
+
import './index-250bdca0.js';
|
|
6
6
|
import 'url';
|
|
7
7
|
import 'tty';
|
|
8
8
|
import 'local-pkg';
|
package/dist/node.d.ts
CHANGED
|
@@ -125,20 +125,18 @@ interface UserConsoleLog {
|
|
|
125
125
|
|
|
126
126
|
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
127
127
|
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
128
|
-
declare type ComputeMode = 'serial' | 'concurrent';
|
|
129
128
|
interface TaskBase {
|
|
130
129
|
id: string;
|
|
131
130
|
name: string;
|
|
132
131
|
mode: RunMode;
|
|
133
|
-
|
|
132
|
+
concurrent?: boolean;
|
|
134
133
|
suite?: Suite;
|
|
135
134
|
file?: File;
|
|
136
135
|
result?: TaskResult;
|
|
137
136
|
}
|
|
138
137
|
interface TaskResult {
|
|
139
138
|
state: TaskState;
|
|
140
|
-
|
|
141
|
-
end?: number;
|
|
139
|
+
duration?: number;
|
|
142
140
|
error?: unknown;
|
|
143
141
|
}
|
|
144
142
|
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
@@ -148,6 +146,7 @@ interface Suite extends TaskBase {
|
|
|
148
146
|
}
|
|
149
147
|
interface File extends Suite {
|
|
150
148
|
filepath: string;
|
|
149
|
+
collectDuration?: number;
|
|
151
150
|
}
|
|
152
151
|
interface Test extends TaskBase {
|
|
153
152
|
type: 'test';
|
|
@@ -237,6 +236,20 @@ interface InlineConfig {
|
|
|
237
236
|
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
238
237
|
*/
|
|
239
238
|
inline?: (string | RegExp)[];
|
|
239
|
+
/**
|
|
240
|
+
* Interpret CJS module's default as named exports
|
|
241
|
+
*
|
|
242
|
+
* @default true
|
|
243
|
+
*/
|
|
244
|
+
interpretDefault?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* When a dependency is a valid ESM package, try to guess the cjs version based on the path.
|
|
247
|
+
* This will significantly improve the performance in huge repo, but might potentially
|
|
248
|
+
* cause some misalignment if a package have different logic in ESM and CJS mode.
|
|
249
|
+
*
|
|
250
|
+
* @default true
|
|
251
|
+
*/
|
|
252
|
+
fallbackCJS?: boolean;
|
|
240
253
|
};
|
|
241
254
|
/**
|
|
242
255
|
* Register apis globally
|
|
@@ -290,7 +303,6 @@ interface InlineConfig {
|
|
|
290
303
|
* @default available CPUs
|
|
291
304
|
*/
|
|
292
305
|
minThreads?: number;
|
|
293
|
-
interpretDefault?: boolean;
|
|
294
306
|
/**
|
|
295
307
|
* Default timeout of a test in milliseconds
|
|
296
308
|
*
|
|
@@ -386,13 +398,20 @@ interface UserConfig extends InlineConfig {
|
|
|
386
398
|
* Pass with no tests
|
|
387
399
|
*/
|
|
388
400
|
passWithNoTests?: boolean;
|
|
401
|
+
/**
|
|
402
|
+
* Run tests that cover a list of source files
|
|
403
|
+
*/
|
|
404
|
+
findRelatedTests?: string[] | string;
|
|
389
405
|
}
|
|
390
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern'> {
|
|
406
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'findRelatedTests'> {
|
|
391
407
|
config?: string;
|
|
392
408
|
filters?: string[];
|
|
393
409
|
testNamePattern?: RegExp;
|
|
410
|
+
findRelatedTests?: string[];
|
|
394
411
|
depsInline: (string | RegExp)[];
|
|
395
412
|
depsExternal: (string | RegExp)[];
|
|
413
|
+
fallbackCJS: boolean;
|
|
414
|
+
interpretDefault: boolean;
|
|
396
415
|
coverage: ResolvedC8Options;
|
|
397
416
|
snapshotOptions: SnapshotStateOptions;
|
|
398
417
|
}
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
2
|
-
import './index-
|
|
1
|
+
export { c as createVitest } from './index-a7ae9662.js';
|
|
2
|
+
import './index-250bdca0.js';
|
|
3
3
|
import 'url';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
@@ -11,10 +11,10 @@ import 'os';
|
|
|
11
11
|
import 'util';
|
|
12
12
|
import 'stream';
|
|
13
13
|
import 'events';
|
|
14
|
-
import './constants-
|
|
14
|
+
import './constants-744cb76d.js';
|
|
15
15
|
import './magic-string.es-94000aea.js';
|
|
16
16
|
import 'perf_hooks';
|
|
17
|
-
import './diff-
|
|
17
|
+
import './diff-a0cbb825.js';
|
|
18
18
|
import './index-648e7ab2.js';
|
|
19
19
|
import './_commonjsHelpers-c9e3b764.js';
|
|
20
20
|
import 'assert';
|
|
@@ -9,11 +9,15 @@ 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-744cb76d.js';
|
|
13
|
+
import { s as shouldExternalize } from './externalize-2f63779d.js';
|
|
14
|
+
import './index-250bdca0.js';
|
|
14
15
|
import 'tty';
|
|
15
16
|
import 'local-pkg';
|
|
16
17
|
import 'path';
|
|
18
|
+
import 'module';
|
|
19
|
+
import 'assert';
|
|
20
|
+
import 'util';
|
|
17
21
|
|
|
18
22
|
/*! (c) 2020 Andrea Giammarchi */
|
|
19
23
|
|
|
@@ -4248,7 +4252,7 @@ function abortHandshake(socket, code, message, headers) {
|
|
|
4248
4252
|
function setup(ctx) {
|
|
4249
4253
|
var _a;
|
|
4250
4254
|
const wss = new websocketServer({ noServer: true });
|
|
4251
|
-
const clients =
|
|
4255
|
+
const clients = new Map();
|
|
4252
4256
|
(_a = ctx.server.httpServer) == null ? void 0 : _a.on("upgrade", (request, socket, head) => {
|
|
4253
4257
|
if (!request.url)
|
|
4254
4258
|
return;
|
|
@@ -4276,6 +4280,35 @@ function setup(ctx) {
|
|
|
4276
4280
|
},
|
|
4277
4281
|
getConfig() {
|
|
4278
4282
|
return ctx.config;
|
|
4283
|
+
},
|
|
4284
|
+
async getModuleGraph(id) {
|
|
4285
|
+
const graph = {};
|
|
4286
|
+
function clearId(id2) {
|
|
4287
|
+
return (id2 == null ? void 0 : id2.replace(/\?v=\w+$/, "")) || "";
|
|
4288
|
+
}
|
|
4289
|
+
function get(mod, seen = new Set()) {
|
|
4290
|
+
if (!mod || !mod.id || seen.has(mod))
|
|
4291
|
+
return;
|
|
4292
|
+
seen.add(mod);
|
|
4293
|
+
const mods = Array.from(mod.importedModules).filter((i) => i.id && !i.id.includes("/vitest/dist/"));
|
|
4294
|
+
graph[clearId(mod.id)] = mods.map((i) => clearId(i.id));
|
|
4295
|
+
mods.forEach((m) => get(m, seen));
|
|
4296
|
+
}
|
|
4297
|
+
get(ctx.server.moduleGraph.getModuleById(id));
|
|
4298
|
+
const externalized = [];
|
|
4299
|
+
const inlined = [];
|
|
4300
|
+
await Promise.all(Object.keys(graph).map(async (i) => {
|
|
4301
|
+
const rewrote = await shouldExternalize(i, ctx.config);
|
|
4302
|
+
if (rewrote)
|
|
4303
|
+
externalized.push(rewrote);
|
|
4304
|
+
else
|
|
4305
|
+
inlined.push(i);
|
|
4306
|
+
}));
|
|
4307
|
+
return {
|
|
4308
|
+
graph,
|
|
4309
|
+
externalized,
|
|
4310
|
+
inlined
|
|
4311
|
+
};
|
|
4279
4312
|
}
|
|
4280
4313
|
},
|
|
4281
4314
|
post(msg) {
|