vitest 0.12.10 → 0.14.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.
Files changed (36) hide show
  1. package/config.d.ts +1 -1
  2. package/dist/{chunk-api-setup.2405c167.js → chunk-api-setup.7945baf8.mjs} +4 -4
  3. package/dist/{chunk-constants.e8bc5d35.js → chunk-constants.41584d81.mjs} +1 -1
  4. package/dist/{chunk-defaults.a3120857.js → chunk-defaults.a820faeb.mjs} +3 -2
  5. package/dist/{chunk-install-pkg.73b84ae1.js → chunk-install-pkg.6f5930c3.mjs} +2 -2
  6. package/dist/chunk-integrations-globals.f0c5e97f.mjs +26 -0
  7. package/dist/{chunk-integrations-spy.bee66426.js → chunk-integrations-spy.674b628e.mjs} +0 -0
  8. package/dist/{chunk-magic-string.41232190.js → chunk-magic-string.efe26975.mjs} +0 -0
  9. package/dist/{chunk-runtime-chain.d2ed2f76.js → chunk-runtime-chain.6a3c6576.mjs} +8 -8
  10. package/dist/{chunk-runtime-mocker.13651a82.js → chunk-runtime-mocker.7cf95199.mjs} +4 -4
  11. package/dist/{chunk-runtime-rpc.d3d38fc1.js → chunk-runtime-rpc.44043bb4.mjs} +1 -1
  12. package/dist/{chunk-utils-global.eb9e6d32.js → chunk-utils-global.624991bc.mjs} +2 -2
  13. package/dist/{chunk-utils-source-map.6b6c39c8.js → chunk-utils-source-map.4408ba82.mjs} +7 -1
  14. package/dist/{chunk-vite-node-externalize.464ab3dd.js → chunk-vite-node-externalize.aaa06ea4.mjs} +8811 -8790
  15. package/dist/{chunk-vite-node-utils.eec5d968.js → chunk-vite-node-utils.d6687931.mjs} +12 -5
  16. package/dist/{cli.js → cli.mjs} +19 -19
  17. package/dist/config.cjs +2 -1
  18. package/dist/config.d.ts +2 -1
  19. package/dist/{config.js → config.mjs} +2 -1
  20. package/dist/entry.mjs +17 -0
  21. package/dist/index.d.ts +15 -7
  22. package/dist/{index.js → index.mjs} +6 -6
  23. package/dist/node.d.ts +13 -6
  24. package/dist/node.mjs +32 -0
  25. package/dist/{spy.js → spy.mjs} +1 -1
  26. package/dist/{vendor-_commonjsHelpers.addc3445.js → vendor-_commonjsHelpers.4da45ef5.mjs} +0 -0
  27. package/dist/{vendor-entry.3113977a.js → vendor-entry.93b045ee.mjs} +7 -7
  28. package/dist/{vendor-index.405e58ef.js → vendor-index.98e769c1.mjs} +0 -0
  29. package/dist/{vendor-index.40be925a.js → vendor-index.a2a385d8.mjs} +407 -407
  30. package/dist/{worker.js → worker.mjs} +6 -6
  31. package/node.d.ts +1 -1
  32. package/package.json +8 -9
  33. package/vitest.mjs +1 -1
  34. package/dist/chunk-integrations-globals.6e996fa7.js +0 -26
  35. package/dist/entry.js +0 -17
  36. package/dist/node.js +0 -32
@@ -1,7 +1,7 @@
1
1
  import { builtinModules, createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
3
3
  import vm from 'vm';
4
- import { m as isAbsolute$2, l as resolve, j as join$2, I as extname$2, d as dirname$2 } from './chunk-utils-global.eb9e6d32.js';
4
+ import { m as isAbsolute$2, l as resolve, j as join$2, I as extname$2, d as dirname$2 } from './chunk-utils-global.624991bc.mjs';
5
5
  import path from 'path';
6
6
  import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
7
7
  import assert from 'assert';
@@ -2776,7 +2776,7 @@ const compare$b = compare_1$1;
2776
2776
  // - If no C has a prerelease and the LT.semver tuple, return false
2777
2777
  // - Else return true
2778
2778
 
2779
- const subset$1 = (sub, dom, options = {}) => {
2779
+ const subset$1 = (sub, dom, options) => {
2780
2780
  if (sub === dom)
2781
2781
  return true
2782
2782
 
@@ -7290,7 +7290,7 @@ const compare = compare_1;
7290
7290
  // - If no C has a prerelease and the LT.semver tuple, return false
7291
7291
  // - Else return true
7292
7292
 
7293
- const subset = (sub, dom, options = {}) => {
7293
+ const subset = (sub, dom, options) => {
7294
7294
  if (sub === dom)
7295
7295
  return true
7296
7296
 
@@ -7948,7 +7948,7 @@ const defaultFindOptions = {
7948
7948
  return null;
7949
7949
  }
7950
7950
  };
7951
- async function findNearestFile(filename, _options = {}) {
7951
+ async function findNearestFile(filename, _options) {
7952
7952
  const options = { ...defaultFindOptions, ..._options };
7953
7953
  const basePath = resolve(options.startingFrom);
7954
7954
  const leadingSlash = basePath[0] === "/";
@@ -8878,6 +8878,13 @@ async function withInlineSourcemap(result) {
8878
8878
  `;
8879
8879
  return result;
8880
8880
  }
8881
+ function toArray(array) {
8882
+ if (array === null || array === void 0)
8883
+ array = [];
8884
+ if (Array.isArray(array))
8885
+ return array;
8886
+ return [array];
8887
+ }
8881
8888
 
8882
8889
  const debugExecute = createDebug("vite-node:client:execute");
8883
8890
  const debugNative = createDebug("vite-node:client:native");
@@ -9170,4 +9177,4 @@ function nanoid(size = 21) {
9170
9177
  return id;
9171
9178
  }
9172
9179
 
9173
- export { ModuleCacheMap as M, ViteNodeRunner as V, isValidNodeImport as a, createBirpc as c, isNodeBuiltin as i, normalizeRequestId as n, slash as s, toFilePath as t, withInlineSourcemap as w };
9180
+ export { ModuleCacheMap as M, ViteNodeRunner as V, isValidNodeImport as a, toFilePath as b, createBirpc as c, isNodeBuiltin as i, normalizeRequestId as n, slash as s, toArray as t, withInlineSourcemap as w };
@@ -1,34 +1,34 @@
1
1
  import { EventEmitter } from 'events';
2
- import { p as picocolors } from './chunk-utils-global.eb9e6d32.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.464ab3dd.js';
2
+ import { p as picocolors } from './chunk-utils-global.624991bc.mjs';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.aaa06ea4.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
- import 'buffer';
8
- import 'child_process';
7
+ import 'vite';
8
+ import 'url';
9
9
  import 'process';
10
- import './vendor-index.40be925a.js';
11
- import './vendor-_commonjsHelpers.addc3445.js';
12
10
  import 'fs';
13
- import 'assert';
14
- import 'stream';
15
- import 'util';
16
- import 'url';
17
- import 'os';
18
- import 'vite';
19
- import './chunk-constants.e8bc5d35.js';
11
+ import './chunk-constants.41584d81.mjs';
20
12
  import 'readline';
21
- import './chunk-vite-node-utils.eec5d968.js';
13
+ import 'os';
14
+ import 'util';
15
+ import 'stream';
16
+ import './vendor-_commonjsHelpers.4da45ef5.mjs';
17
+ import './chunk-vite-node-utils.d6687931.mjs';
22
18
  import 'module';
23
19
  import 'vm';
20
+ import 'assert';
24
21
  import 'debug';
25
- import './chunk-defaults.a3120857.js';
22
+ import './chunk-defaults.a820faeb.mjs';
26
23
  import 'worker_threads';
27
24
  import 'tinypool';
28
25
  import 'perf_hooks';
29
- import './chunk-utils-source-map.6b6c39c8.js';
30
- import './chunk-magic-string.41232190.js';
31
- import './vendor-index.405e58ef.js';
26
+ import './chunk-utils-source-map.4408ba82.mjs';
27
+ import './vendor-index.a2a385d8.mjs';
28
+ import 'child_process';
29
+ import 'buffer';
30
+ import './chunk-magic-string.efe26975.mjs';
31
+ import './vendor-index.98e769c1.mjs';
32
32
 
33
33
  function toArr(any) {
34
34
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -641,7 +641,7 @@ class CAC extends EventEmitter {
641
641
  }
642
642
  }
643
643
 
644
- const cac = (name = "") => new CAC(name);
644
+ const cac = (name) => new CAC(name);
645
645
 
646
646
  const cli = cac("vitest");
647
647
  cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of mutliple reporters").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").help();
package/dist/config.cjs CHANGED
@@ -54,7 +54,8 @@ const config = {
54
54
  testTimeout: 5e3,
55
55
  hookTimeout: 1e4,
56
56
  isolate: true,
57
- watchIgnore: [/\/node_modules\//, /\/dist\//],
57
+ watchExclude: ["**/node_modules/**", "**/dist/**"],
58
+ forceRerunTriggers: [],
58
59
  update: false,
59
60
  reporters: [],
60
61
  silent: false,
package/dist/config.d.ts CHANGED
@@ -82,7 +82,8 @@ declare const config: {
82
82
  testTimeout: number;
83
83
  hookTimeout: number;
84
84
  isolate: boolean;
85
- watchIgnore: RegExp[];
85
+ watchExclude: string[];
86
+ forceRerunTriggers: never[];
86
87
  update: boolean;
87
88
  reporters: never[];
88
89
  silent: boolean;
@@ -50,7 +50,8 @@ const config = {
50
50
  testTimeout: 5e3,
51
51
  hookTimeout: 1e4,
52
52
  isolate: true,
53
- watchIgnore: [/\/node_modules\//, /\/dist\//],
53
+ watchExclude: ["**/node_modules/**", "**/dist/**"],
54
+ forceRerunTriggers: [],
54
55
  update: false,
55
56
  reporters: [],
56
57
  silent: false,
package/dist/entry.mjs ADDED
@@ -0,0 +1,17 @@
1
+ export { r as run } from './vendor-entry.93b045ee.mjs';
2
+ import 'fs';
3
+ import './chunk-utils-global.624991bc.mjs';
4
+ import 'tty';
5
+ import 'local-pkg';
6
+ import 'path';
7
+ import './chunk-runtime-chain.6a3c6576.mjs';
8
+ import 'chai';
9
+ import './vendor-_commonjsHelpers.4da45ef5.mjs';
10
+ import './chunk-runtime-rpc.44043bb4.mjs';
11
+ import './chunk-utils-source-map.4408ba82.mjs';
12
+ import './chunk-integrations-spy.674b628e.mjs';
13
+ import 'tinyspy';
14
+ import 'util';
15
+ import './chunk-defaults.a820faeb.mjs';
16
+ import 'module';
17
+ import 'url';
package/dist/index.d.ts CHANGED
@@ -192,10 +192,9 @@ declare class ViteNodeRunner {
192
192
  hasNestedDefault(target: any): any;
193
193
  private debugLog;
194
194
  }
195
-
196
195
  interface DepsHandlingOptions {
197
196
  external?: (string | RegExp)[];
198
- inline?: (string | RegExp)[];
197
+ inline?: (string | RegExp)[] | true;
199
198
  /**
200
199
  * Try to guess the CJS version of a package when it's invalid ESM
201
200
  * @default false
@@ -733,7 +732,7 @@ interface Test<ExtraContext = {}> extends TaskBase {
733
732
  }
734
733
  declare type Task = Test | Suite | File;
735
734
  declare type DoneCallback = (error?: any) => void;
736
- declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<void>;
735
+ declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
737
736
  declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
738
737
  1: [T[0]];
739
738
  2: [T[0], T[1]];
@@ -910,8 +909,10 @@ interface InlineConfig {
910
909
  * Vite will process inlined modules.
911
910
  *
912
911
  * This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
912
+ *
913
+ * If `true`, every dependency will be inlined
913
914
  */
914
- inline?: (string | RegExp)[];
915
+ inline?: (string | RegExp)[] | true;
915
916
  /**
916
917
  * Interpret CJS module's default as named exports
917
918
  *
@@ -1028,11 +1029,17 @@ interface InlineConfig {
1028
1029
  */
1029
1030
  globalSetup?: string | string[];
1030
1031
  /**
1031
- * Pattern of file paths to be ignore from triggering watch rerun
1032
+ * Glob pattern of file paths to be ignore from triggering watch rerun
1033
+ */
1034
+ watchExclude?: string[];
1035
+ /**
1036
+ * Glob patter of file paths that will trigger the whole suite rerun
1032
1037
  *
1033
- * @default [/\/node_modules\//, /\/dist\//]
1038
+ * Useful if you are testing calling CLI commands
1039
+ *
1040
+ * @default []
1034
1041
  */
1035
- watchIgnore?: (string | RegExp)[];
1042
+ forceRerunTriggers?: string[];
1036
1043
  /**
1037
1044
  * Isolate environment for each test file
1038
1045
  *
@@ -1521,6 +1528,7 @@ declare type Classes<T> = {
1521
1528
  [K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never;
1522
1529
  }[keyof T] & (string | symbol);
1523
1530
  interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
1531
+ (...args: TArgs): TReturns;
1524
1532
  getMockName(): string;
1525
1533
  mockName(n: string): this;
1526
1534
  mock: SpyContext<TArgs, TReturns>;
@@ -1,13 +1,13 @@
1
- export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.d2ed2f76.js';
1
+ export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.6a3c6576.mjs';
2
2
  export { assert, default as chai, should } from 'chai';
3
- import './vendor-_commonjsHelpers.addc3445.js';
4
- import './chunk-runtime-rpc.d3d38fc1.js';
5
- import './chunk-utils-global.eb9e6d32.js';
3
+ import './vendor-_commonjsHelpers.4da45ef5.mjs';
4
+ import './chunk-runtime-rpc.44043bb4.mjs';
5
+ import './chunk-utils-global.624991bc.mjs';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
9
9
  import 'fs';
10
- import './chunk-utils-source-map.6b6c39c8.js';
11
- import './chunk-integrations-spy.bee66426.js';
10
+ import './chunk-utils-source-map.4408ba82.mjs';
11
+ import './chunk-integrations-spy.674b628e.mjs';
12
12
  import 'tinyspy';
13
13
  import 'util';
package/dist/node.d.ts CHANGED
@@ -36,10 +36,9 @@ declare class ViteNodeRunner {
36
36
  hasNestedDefault(target: any): any;
37
37
  private debugLog;
38
38
  }
39
-
40
39
  interface DepsHandlingOptions {
41
40
  external?: (string | RegExp)[];
42
- inline?: (string | RegExp)[];
41
+ inline?: (string | RegExp)[] | true;
43
42
  /**
44
43
  * Try to guess the CJS version of a package when it's invalid ESM
45
44
  * @default false
@@ -729,8 +728,10 @@ interface InlineConfig {
729
728
  * Vite will process inlined modules.
730
729
  *
731
730
  * This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
731
+ *
732
+ * If `true`, every dependency will be inlined
732
733
  */
733
- inline?: (string | RegExp)[];
734
+ inline?: (string | RegExp)[] | true;
734
735
  /**
735
736
  * Interpret CJS module's default as named exports
736
737
  *
@@ -847,11 +848,17 @@ interface InlineConfig {
847
848
  */
848
849
  globalSetup?: string | string[];
849
850
  /**
850
- * Pattern of file paths to be ignore from triggering watch rerun
851
+ * Glob pattern of file paths to be ignore from triggering watch rerun
852
+ */
853
+ watchExclude?: string[];
854
+ /**
855
+ * Glob patter of file paths that will trigger the whole suite rerun
856
+ *
857
+ * Useful if you are testing calling CLI commands
851
858
  *
852
- * @default [/\/node_modules\//, /\/dist\//]
859
+ * @default []
853
860
  */
854
- watchIgnore?: (string | RegExp)[];
861
+ forceRerunTriggers?: string[];
855
862
  /**
856
863
  * Isolate environment for each test file
857
864
  *
package/dist/node.mjs ADDED
@@ -0,0 +1,32 @@
1
+ export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.aaa06ea4.mjs';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.7cf95199.mjs';
3
+ import './chunk-utils-global.624991bc.mjs';
4
+ import 'tty';
5
+ import 'local-pkg';
6
+ import 'path';
7
+ import 'vite';
8
+ import 'url';
9
+ import 'process';
10
+ import 'fs';
11
+ import './chunk-constants.41584d81.mjs';
12
+ import 'readline';
13
+ import 'os';
14
+ import 'util';
15
+ import 'stream';
16
+ import 'events';
17
+ import './vendor-_commonjsHelpers.4da45ef5.mjs';
18
+ import './chunk-vite-node-utils.d6687931.mjs';
19
+ import 'module';
20
+ import 'vm';
21
+ import 'assert';
22
+ import 'debug';
23
+ import './chunk-defaults.a820faeb.mjs';
24
+ import 'worker_threads';
25
+ import 'tinypool';
26
+ import 'perf_hooks';
27
+ import './chunk-utils-source-map.4408ba82.mjs';
28
+ import './vendor-index.a2a385d8.mjs';
29
+ import 'child_process';
30
+ import 'buffer';
31
+ import './chunk-magic-string.efe26975.mjs';
32
+ import './vendor-index.98e769c1.mjs';
@@ -1,2 +1,2 @@
1
- export { f as fn, i as isMockFunction, a as spies, s as spyOn } from './chunk-integrations-spy.bee66426.js';
1
+ export { f as fn, i as isMockFunction, a as spies, s as spyOn } from './chunk-integrations-spy.674b628e.mjs';
2
2
  import 'tinyspy';
@@ -1,12 +1,12 @@
1
1
  import { promises } from 'fs';
2
- import { q as isNode, a as getWorkerState, f as safeClearTimeout, e as safeSetTimeout, t as toArray, N as clone, L as getType, o as relative, O as partitionSuiteChildren, P as hasTests, x as hasFailed, v as getFullName, r as resetModules } from './chunk-utils-global.eb9e6d32.js';
2
+ import { q as isNode, a as getWorkerState, f as safeClearTimeout, e as safeSetTimeout, t as toArray, N as clone, L as getType, o as relative, O as partitionSuiteChildren, P as hasTests, x as hasFailed, v as getFullName, r as resetModules } from './chunk-utils-global.624991bc.mjs';
3
3
  import { importModule } from 'local-pkg';
4
- import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.d2ed2f76.js';
4
+ import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.6a3c6576.mjs';
5
5
  import chai, { assert, should, util } from 'chai';
6
- import { r as rpc } from './chunk-runtime-rpc.d3d38fc1.js';
7
- import { t as takeCoverage } from './chunk-defaults.a3120857.js';
6
+ import { r as rpc } from './chunk-runtime-rpc.44043bb4.mjs';
7
+ import { t as takeCoverage } from './chunk-defaults.a820faeb.mjs';
8
8
  import { format } from 'util';
9
- import { s as stringify } from './chunk-utils-source-map.6b6c39c8.js';
9
+ import { s as stringify } from './chunk-utils-source-map.4408ba82.mjs';
10
10
 
11
11
  var index = /*#__PURE__*/Object.freeze({
12
12
  __proto__: null,
@@ -284,7 +284,7 @@ function getWindowKeys(global, win) {
284
284
  function isClassLikeName(name) {
285
285
  return name[0] === name[0].toUpperCase();
286
286
  }
287
- function populateGlobal(global, win, options = {}) {
287
+ function populateGlobal(global, win, options) {
288
288
  const { bindFunctions = false } = options;
289
289
  const keys = getWindowKeys(global, win);
290
290
  const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
@@ -435,7 +435,7 @@ async function setupGlobalEnv(config) {
435
435
  if (isNode)
436
436
  await setupConsoleLogSpy();
437
437
  if (config.globals)
438
- (await import('./chunk-integrations-globals.6e996fa7.js')).registerApiGlobally();
438
+ (await import('./chunk-integrations-globals.f0c5e97f.mjs')).registerApiGlobally();
439
439
  }
440
440
  function setupDefines(defines) {
441
441
  for (const key in defines)