vitest 0.19.1 → 0.20.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 (34) hide show
  1. package/dist/browser.d.ts +43 -3
  2. package/dist/browser.mjs +9 -7
  3. package/dist/{chunk-api-setup.0cf2c96a.mjs → chunk-api-setup.7c4c8879.mjs} +7 -6
  4. package/dist/{chunk-constants.38b43a44.mjs → chunk-constants.16825f0c.mjs} +3 -2
  5. package/dist/{chunk-defaults.ed196a9a.mjs → chunk-defaults.1c51d585.mjs} +6 -4
  6. package/dist/chunk-integrations-globals.56a11010.mjs +26 -0
  7. package/dist/{chunk-utils-global.2aa95025.mjs → chunk-mock-date.9160e13b.mjs} +6 -36
  8. package/dist/{chunk-node-git.9058b82a.mjs → chunk-node-git.43dbdd42.mjs} +1 -1
  9. package/dist/{chunk-runtime-chain.f2e00f4c.mjs → chunk-runtime-chain.b6c2cdbc.mjs} +5 -3
  10. package/dist/{chunk-runtime-error.606e0393.mjs → chunk-runtime-error.0aa0dc06.mjs} +17 -13
  11. package/dist/{chunk-runtime-hooks.d4cadf47.mjs → chunk-runtime-hooks.3ee34848.mjs} +7 -4
  12. package/dist/{chunk-runtime-mocker.dfdfd57b.mjs → chunk-runtime-mocker.0a8f7c5e.mjs} +23 -17
  13. package/dist/{chunk-runtime-rpc.45d8ee19.mjs → chunk-runtime-rpc.dbf0b31d.mjs} +3 -1
  14. package/dist/chunk-utils-global.fa20c2f6.mjs +5 -0
  15. package/dist/{chunk-utils-source-map.8b066ce2.mjs → chunk-utils-source-map.8198ebd9.mjs} +1 -1
  16. package/dist/chunk-utils-timers.b48455ed.mjs +27 -0
  17. package/dist/chunk-vite-node-client.a247c2c2.mjs +320 -0
  18. package/dist/chunk-vite-node-debug.c5887932.mjs +76 -0
  19. package/dist/{chunk-vite-node-externalize.e9af6472.mjs → chunk-vite-node-externalize.2e90dadf.mjs} +72 -19
  20. package/dist/{chunk-vite-node-utils.ad73f2ab.mjs → chunk-vite-node-utils.9dfd1e3f.mjs} +4 -323
  21. package/dist/cli.mjs +9 -7
  22. package/dist/config.cjs +3 -2
  23. package/dist/config.d.ts +1 -0
  24. package/dist/config.mjs +3 -2
  25. package/dist/entry.mjs +10 -8
  26. package/dist/index.d.ts +44 -4
  27. package/dist/index.mjs +7 -5
  28. package/dist/loader.mjs +35 -0
  29. package/dist/node.d.ts +44 -3
  30. package/dist/node.mjs +10 -7
  31. package/dist/suite.mjs +6 -4
  32. package/dist/worker.mjs +9 -6
  33. package/package.json +4 -4
  34. package/dist/chunk-integrations-globals.1018e651.mjs +0 -24
package/dist/node.d.ts CHANGED
@@ -108,7 +108,6 @@ declare class ViteNodeRunner {
108
108
  */
109
109
  interopedImport(path: string): Promise<any>;
110
110
  hasNestedDefault(target: any): any;
111
- private debugLog;
112
111
  }
113
112
  interface DepsHandlingOptions {
114
113
  external?: (string | RegExp)[];
@@ -179,6 +178,33 @@ interface ViteNodeServerOptions {
179
178
  ssr?: RegExp[];
180
179
  web?: RegExp[];
181
180
  };
181
+ debug?: DebuggerOptions;
182
+ }
183
+ interface DebuggerOptions {
184
+ /**
185
+ * Dump the transformed module to filesystem
186
+ * Passing a string will dump to the specified path
187
+ */
188
+ dumpModules?: boolean | string;
189
+ /**
190
+ * Read dumpped module from filesystem whenever exists.
191
+ * Useful for debugging by modifying the dump result from the filesystem.
192
+ */
193
+ loadDumppedModules?: boolean;
194
+ }
195
+
196
+ declare class Debugger {
197
+ options: DebuggerOptions;
198
+ dumpDir: string | undefined;
199
+ initPromise: Promise<void> | undefined;
200
+ externalizeMap: Map<string, string>;
201
+ constructor(root: string, options: DebuggerOptions);
202
+ clearDump(): Promise<void>;
203
+ encodeId(id: string): string;
204
+ recordExternalize(id: string, path: string): Promise<void>;
205
+ dumpFile(id: string, result: TransformResult | null): Promise<void>;
206
+ loadDump(id: string): Promise<TransformResult | null>;
207
+ writeInfo(): Promise<void>;
182
208
  }
183
209
 
184
210
  declare class ViteNodeServer {
@@ -190,6 +216,8 @@ declare class ViteNodeServer {
190
216
  timestamp: number;
191
217
  result: FetchResult;
192
218
  }>;
219
+ externalizeCache: Map<string, Promise<string | false>>;
220
+ debugger?: Debugger;
193
221
  constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
194
222
  shouldExternalize(id: string): Promise<string | false>;
195
223
  resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
@@ -721,6 +749,7 @@ interface Suite extends TaskBase {
721
749
  interface File extends Suite {
722
750
  filepath: string;
723
751
  collectDuration?: number;
752
+ setupDuration?: number;
724
753
  }
725
754
  interface Test<ExtraContext = {}> extends TaskBase {
726
755
  type: 'test';
@@ -1161,6 +1190,10 @@ interface InlineConfig {
1161
1190
  * Will be merged with the default aliases inside `resolve.alias`.
1162
1191
  */
1163
1192
  alias?: AliasOptions;
1193
+ /**
1194
+ * Ignore any unhandled errors that occur
1195
+ */
1196
+ dangerouslyIgnoreUnhandledErrors?: boolean;
1164
1197
  }
1165
1198
  interface UserConfig extends InlineConfig {
1166
1199
  /**
@@ -1503,16 +1536,23 @@ interface WorkerPool {
1503
1536
  close: () => Promise<void>;
1504
1537
  }
1505
1538
 
1539
+ interface CollectingPromise {
1540
+ promise: Promise<void>;
1541
+ resolve: () => void;
1542
+ }
1506
1543
  declare class StateManager {
1507
1544
  filesMap: Map<string, File>;
1508
1545
  pathsSet: Set<string>;
1546
+ collectingPromise: CollectingPromise | undefined;
1509
1547
  idMap: Map<string, Task>;
1510
1548
  taskFileMap: WeakMap<Task, File>;
1511
1549
  errorsSet: Set<unknown>;
1512
1550
  catchError(err: unknown, type: string): void;
1513
1551
  clearErrors(): void;
1514
1552
  getUnhandledErrors(): unknown[];
1515
- getPaths(): string[];
1553
+ startCollectingPaths(): void;
1554
+ finishCollectingPaths(): void;
1555
+ getPaths(): Promise<string[]>;
1516
1556
  getFiles(keys?: string[]): File[];
1517
1557
  getFilepaths(): string[];
1518
1558
  getFailedFilepaths(): string[];
@@ -1645,7 +1685,8 @@ declare class VitestMocker {
1645
1685
  private resolvePath;
1646
1686
  private resolveMocks;
1647
1687
  private callFunctionMock;
1648
- getDependencyMock(dep: string): string | (() => unknown) | null;
1688
+ private getMockPath;
1689
+ getDependencyMock(id: string): string | (() => unknown) | null;
1649
1690
  normalizePath(path: string): string;
1650
1691
  getFsPath(path: string, external: string | null): string;
1651
1692
  resolveMockPath(mockPath: string, external: string | null): string | null;
package/dist/node.mjs CHANGED
@@ -1,31 +1,34 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.e9af6472.mjs';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.dfdfd57b.mjs';
3
- import './chunk-utils-global.2aa95025.mjs';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.2e90dadf.mjs';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.0a8f7c5e.mjs';
3
+ import './chunk-mock-date.9160e13b.mjs';
4
4
  import 'path';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
- import './chunk-defaults.ed196a9a.mjs';
7
+ import './chunk-defaults.1c51d585.mjs';
8
8
  import 'fs';
9
9
  import 'module';
10
10
  import 'url';
11
11
  import 'vite';
12
12
  import 'process';
13
- import './chunk-constants.38b43a44.mjs';
13
+ import './chunk-constants.16825f0c.mjs';
14
14
  import 'os';
15
15
  import 'util';
16
16
  import 'stream';
17
17
  import 'events';
18
18
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
19
- import './chunk-vite-node-utils.ad73f2ab.mjs';
19
+ import './chunk-vite-node-client.a247c2c2.mjs';
20
20
  import 'vm';
21
+ import './chunk-vite-node-utils.9dfd1e3f.mjs';
21
22
  import 'assert';
22
23
  import 'debug';
23
24
  import 'worker_threads';
24
25
  import 'tinypool';
25
26
  import 'perf_hooks';
26
- import './chunk-utils-source-map.8b066ce2.mjs';
27
+ import './chunk-utils-source-map.8198ebd9.mjs';
28
+ import './chunk-utils-timers.b48455ed.mjs';
27
29
  import 'crypto';
28
30
  import './vendor-index.61438b77.mjs';
29
31
  import './chunk-magic-string.efe26975.mjs';
30
32
  import 'readline';
31
33
  import './vendor-index.de788b6a.mjs';
34
+ import './chunk-utils-global.fa20c2f6.mjs';
package/dist/suite.mjs CHANGED
@@ -1,13 +1,15 @@
1
1
  import 'util';
2
- import './chunk-utils-global.2aa95025.mjs';
3
- export { e as clearCollectorContext, o as createSuiteHooks, f as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.f2e00f4c.mjs';
2
+ import './chunk-mock-date.9160e13b.mjs';
3
+ export { e as clearCollectorContext, o as createSuiteHooks, f as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.b6c2cdbc.mjs';
4
+ import './chunk-utils-global.fa20c2f6.mjs';
4
5
  import 'path';
5
6
  import 'tty';
6
7
  import 'local-pkg';
7
8
  import 'chai';
8
9
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
9
- import './chunk-runtime-rpc.45d8ee19.mjs';
10
+ import './chunk-runtime-rpc.dbf0b31d.mjs';
11
+ import './chunk-utils-timers.b48455ed.mjs';
10
12
  import 'fs';
11
- import './chunk-utils-source-map.8b066ce2.mjs';
13
+ import './chunk-utils-source-map.8198ebd9.mjs';
12
14
  import './spy.mjs';
13
15
  import 'tinyspy';
package/dist/worker.mjs CHANGED
@@ -1,20 +1,23 @@
1
- import { C as resolve, g as getWorkerState } from './chunk-utils-global.2aa95025.mjs';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.ad73f2ab.mjs';
1
+ import { y as resolve } from './chunk-mock-date.9160e13b.mjs';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.a247c2c2.mjs';
3
3
  import { workerId } from 'tinypool';
4
- import { d as distDir } from './chunk-constants.38b43a44.mjs';
5
- import { e as executeInViteNode } from './chunk-runtime-mocker.dfdfd57b.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.45d8ee19.mjs';
4
+ import { d as distDir } from './chunk-constants.16825f0c.mjs';
5
+ import { e as executeInViteNode } from './chunk-runtime-mocker.0a8f7c5e.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.dbf0b31d.mjs';
7
+ import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
7
8
  import 'path';
8
9
  import 'tty';
9
10
  import 'local-pkg';
10
11
  import 'module';
11
12
  import 'url';
12
13
  import 'vm';
14
+ import './chunk-vite-node-utils.9dfd1e3f.mjs';
13
15
  import 'fs';
14
16
  import 'assert';
15
17
  import 'util';
16
18
  import 'debug';
17
19
  import 'vite';
20
+ import './chunk-utils-timers.b48455ed.mjs';
18
21
 
19
22
  let _viteNode;
20
23
  const moduleCache = new ModuleCacheMap();
@@ -77,7 +80,7 @@ function init(ctx) {
77
80
  if (ctx.invalidates) {
78
81
  ctx.invalidates.forEach((fsPath) => {
79
82
  moduleCache.delete(fsPath);
80
- moduleCache.delete(`${fsPath}__mock`);
83
+ moduleCache.delete(`mock:${fsPath}`);
81
84
  });
82
85
  }
83
86
  ctx.files.forEach((i) => moduleCache.delete(i));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.19.1",
3
+ "version": "0.20.0",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -109,7 +109,7 @@
109
109
  "@types/natural-compare": "^1.4.1",
110
110
  "@types/prompts": "^2.4.0",
111
111
  "@types/sinonjs__fake-timers": "^8.1.2",
112
- "@vitest/ui": "0.19.1",
112
+ "@vitest/ui": "0.20.0",
113
113
  "birpc": "^0.2.3",
114
114
  "c8": "^7.11.3",
115
115
  "cac": "^6.7.12",
@@ -137,11 +137,11 @@
137
137
  "source-map-js": "^1.0.2",
138
138
  "strip-ansi": "^7.0.1",
139
139
  "typescript": "^4.7.4",
140
- "vite-node": "0.19.1",
140
+ "vite-node": "0.20.0",
141
141
  "ws": "^8.8.1"
142
142
  },
143
143
  "scripts": {
144
144
  "build": "rimraf dist && rollup -c",
145
- "dev": "rollup -c --watch -m inline"
145
+ "dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" rollup -c --watch -m inline"
146
146
  }
147
147
  }
@@ -1,24 +0,0 @@
1
- import { g as globalApis } from './chunk-constants.38b43a44.mjs';
2
- import { i as index } from './chunk-runtime-hooks.d4cadf47.mjs';
3
- import 'url';
4
- import './chunk-utils-global.2aa95025.mjs';
5
- import 'path';
6
- import 'tty';
7
- import 'local-pkg';
8
- import './chunk-runtime-chain.f2e00f4c.mjs';
9
- import 'util';
10
- import 'chai';
11
- import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
- import './chunk-runtime-rpc.45d8ee19.mjs';
13
- import 'fs';
14
- import './chunk-utils-source-map.8b066ce2.mjs';
15
- import './spy.mjs';
16
- import 'tinyspy';
17
-
18
- function registerApiGlobally() {
19
- globalApis.forEach((api) => {
20
- globalThis[api] = index[api];
21
- });
22
- }
23
-
24
- export { registerApiGlobally };