vitest 0.14.1 → 0.15.1

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 (25) hide show
  1. package/dist/{chunk-api-setup.7945baf8.mjs → chunk-api-setup.ff687d0e.mjs} +44 -37
  2. package/dist/{chunk-constants.41584d81.mjs → chunk-constants.7b9cfc82.mjs} +1 -1
  3. package/dist/{chunk-defaults.a820faeb.mjs → chunk-defaults.dc6dc23d.mjs} +142 -3
  4. package/dist/{chunk-install-pkg.6f5930c3.mjs → chunk-install-pkg.3fa50769.mjs} +1 -1
  5. package/dist/{chunk-integrations-globals.f0c5e97f.mjs → chunk-integrations-globals.df0878f4.mjs} +7 -7
  6. package/dist/{chunk-runtime-chain.6a3c6576.mjs → chunk-runtime-chain.ce7f4b92.mjs} +117 -64
  7. package/dist/{chunk-runtime-mocker.7cf95199.mjs → chunk-runtime-mocker.2f3cbfe5.mjs} +3 -3
  8. package/dist/{chunk-runtime-rpc.44043bb4.mjs → chunk-runtime-rpc.5e78af38.mjs} +1 -1
  9. package/dist/{chunk-utils-global.624991bc.mjs → chunk-utils-global.79a8b1cc.mjs} +15 -8
  10. package/dist/{chunk-utils-source-map.4408ba82.mjs → chunk-utils-source-map.2556cba8.mjs} +29 -14
  11. package/dist/{chunk-vite-node-externalize.d492e389.mjs → chunk-vite-node-externalize.105bc106.mjs} +105 -165
  12. package/dist/{chunk-vite-node-utils.d6687931.mjs → chunk-vite-node-utils.c0a0e1b3.mjs} +4 -4
  13. package/dist/cli.mjs +11 -10
  14. package/dist/config.cjs +5 -1
  15. package/dist/config.d.ts +4 -0
  16. package/dist/config.mjs +5 -1
  17. package/dist/entry.mjs +6 -6
  18. package/dist/index.d.ts +36 -4
  19. package/dist/index.mjs +4 -4
  20. package/dist/node.d.ts +32 -1
  21. package/dist/node.mjs +10 -9
  22. package/dist/{vendor-entry.93b045ee.mjs → vendor-entry.7ec02ea2.mjs} +41 -27
  23. package/dist/{vendor-index.a2a385d8.mjs → vendor-index.e5dc6622.mjs} +0 -0
  24. package/dist/worker.mjs +8 -7
  25. package/package.json +9 -8
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
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.d492e389.mjs';
2
+ import { p as picocolors } from './chunk-utils-global.79a8b1cc.mjs';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.105bc106.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
@@ -8,23 +8,24 @@ import 'vite';
8
8
  import 'url';
9
9
  import 'process';
10
10
  import 'fs';
11
- import './chunk-constants.41584d81.mjs';
11
+ import './chunk-defaults.dc6dc23d.mjs';
12
+ import 'module';
13
+ import './chunk-constants.7b9cfc82.mjs';
12
14
  import 'readline';
13
15
  import 'os';
14
16
  import 'util';
15
17
  import 'stream';
16
18
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
17
- import './chunk-vite-node-utils.d6687931.mjs';
18
- import 'module';
19
+ import './chunk-vite-node-utils.c0a0e1b3.mjs';
19
20
  import 'vm';
20
21
  import 'assert';
21
22
  import 'debug';
22
- import './chunk-defaults.a820faeb.mjs';
23
23
  import 'worker_threads';
24
+ import 'crypto';
24
25
  import 'tinypool';
25
26
  import 'perf_hooks';
26
- import './chunk-utils-source-map.4408ba82.mjs';
27
- import './vendor-index.a2a385d8.mjs';
27
+ import './chunk-utils-source-map.2556cba8.mjs';
28
+ import './vendor-index.e5dc6622.mjs';
28
29
  import 'child_process';
29
30
  import 'buffer';
30
31
  import './chunk-magic-string.efe26975.mjs';
@@ -641,10 +642,10 @@ class CAC extends EventEmitter {
641
642
  }
642
643
  }
643
644
 
644
- const cac = (name) => new CAC(name);
645
+ const cac = (name = "") => new CAC(name);
645
646
 
646
647
  const cli = cac("vitest");
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();
648
+ 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 (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").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("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").help();
648
649
  cli.command("run [...filters]").action(run);
649
650
  cli.command("related [...filters]").action(runRelated);
650
651
  cli.command("watch [...filters]").action(start);
package/dist/config.cjs CHANGED
@@ -63,8 +63,12 @@ const config = {
63
63
  ui: false,
64
64
  uiBase: "/__vitest__/",
65
65
  open: true,
66
+ css: {
67
+ include: [/\.module\./]
68
+ },
66
69
  coverage: coverageConfigDefaults,
67
- fakeTimers: fakeTimersDefaults
70
+ fakeTimers: fakeTimersDefaults,
71
+ maxConcurrency: 5
68
72
  };
69
73
  const configDefaults = Object.freeze(config);
70
74
 
package/dist/config.d.ts CHANGED
@@ -91,8 +91,12 @@ declare const config: {
91
91
  ui: boolean;
92
92
  uiBase: string;
93
93
  open: boolean;
94
+ css: {
95
+ include: RegExp[];
96
+ };
94
97
  coverage: ResolvedC8Options;
95
98
  fakeTimers: FakeTimerInstallOpts;
99
+ maxConcurrency: number;
96
100
  };
97
101
  declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
98
102
 
package/dist/config.mjs CHANGED
@@ -59,8 +59,12 @@ const config = {
59
59
  ui: false,
60
60
  uiBase: "/__vitest__/",
61
61
  open: true,
62
+ css: {
63
+ include: [/\.module\./]
64
+ },
62
65
  coverage: coverageConfigDefaults,
63
- fakeTimers: fakeTimersDefaults
66
+ fakeTimers: fakeTimersDefaults,
67
+ maxConcurrency: 5
64
68
  };
65
69
  const configDefaults = Object.freeze(config);
66
70
 
package/dist/entry.mjs CHANGED
@@ -1,17 +1,17 @@
1
- export { r as run } from './vendor-entry.93b045ee.mjs';
1
+ export { r as run } from './vendor-entry.7ec02ea2.mjs';
2
2
  import 'fs';
3
- import './chunk-utils-global.624991bc.mjs';
3
+ import './chunk-utils-global.79a8b1cc.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
- import './chunk-runtime-chain.6a3c6576.mjs';
7
+ import './chunk-runtime-chain.ce7f4b92.mjs';
8
8
  import 'chai';
9
9
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
10
- import './chunk-runtime-rpc.44043bb4.mjs';
11
- import './chunk-utils-source-map.4408ba82.mjs';
10
+ import './chunk-runtime-rpc.5e78af38.mjs';
11
+ import './chunk-utils-source-map.2556cba8.mjs';
12
12
  import './chunk-integrations-spy.674b628e.mjs';
13
13
  import 'tinyspy';
14
14
  import 'util';
15
- import './chunk-defaults.a820faeb.mjs';
15
+ import './chunk-defaults.dc6dc23d.mjs';
16
16
  import 'module';
17
17
  import 'url';
package/dist/index.d.ts CHANGED
@@ -979,6 +979,10 @@ interface InlineConfig {
979
979
  * diff output length
980
980
  */
981
981
  outputTruncateLength?: number;
982
+ /**
983
+ * number of diff output lines
984
+ */
985
+ outputDiffLines?: number;
982
986
  /**
983
987
  * Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
984
988
  * Also definable individually per reporter by using an object instead.
@@ -1148,6 +1152,22 @@ interface InlineConfig {
1148
1152
  * Return `false` to ignore the log.
1149
1153
  */
1150
1154
  onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
1155
+ /**
1156
+ * Indicates if CSS files should be processed.
1157
+ *
1158
+ * When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
1159
+ *
1160
+ * @default { include: [/\.module\./] }
1161
+ */
1162
+ css?: boolean | {
1163
+ include?: RegExp | RegExp[];
1164
+ exclude?: RegExp | RegExp[];
1165
+ };
1166
+ /**
1167
+ * A number of tests that are allowed to run at the same time marked with `test.concurrent`.
1168
+ * @default 5
1169
+ */
1170
+ maxConcurrency?: number;
1151
1171
  }
1152
1172
  interface UserConfig extends InlineConfig {
1153
1173
  /**
@@ -1179,8 +1199,15 @@ interface UserConfig extends InlineConfig {
1179
1199
  * @default false
1180
1200
  */
1181
1201
  changed?: boolean | string;
1202
+ /**
1203
+ * Test suite shard to execute in a format of <index>/<count>.
1204
+ * Will divide tests into a `count` numbers, and run only the `indexed` part.
1205
+ * Cannot be used with enabled watch.
1206
+ * @example --shard=2/3
1207
+ */
1208
+ shard?: string;
1182
1209
  }
1183
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath'> {
1210
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard'> {
1184
1211
  base?: string;
1185
1212
  config?: string;
1186
1213
  filters?: string[];
@@ -1191,6 +1218,10 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
1191
1218
  reporters: (Reporter | BuiltinReporters)[];
1192
1219
  defines: Record<string, any>;
1193
1220
  api?: ApiConfig;
1221
+ shard?: {
1222
+ index: number;
1223
+ count: number;
1224
+ };
1194
1225
  }
1195
1226
 
1196
1227
  declare type VitestInlineConfig = InlineConfig;
@@ -1467,7 +1498,8 @@ declare type BirpcReturn<RemoteFunctions> = {
1467
1498
  };
1468
1499
 
1469
1500
  interface WorkerContext {
1470
- id: number;
1501
+ workerId: number;
1502
+ poolId: number;
1471
1503
  port: MessagePort;
1472
1504
  config: ResolvedConfig;
1473
1505
  files: string[];
@@ -1613,7 +1645,7 @@ declare function runOnce<T>(fn: (() => T), key?: string): T;
1613
1645
  declare function isFirstRun(): boolean;
1614
1646
 
1615
1647
  declare function createExpect(test?: Test): Vi.ExpectStatic;
1616
- declare const expect: Vi.ExpectStatic;
1648
+ declare const globalExpect: Vi.ExpectStatic;
1617
1649
 
1618
1650
  declare class VitestUtils {
1619
1651
  private _timers;
@@ -1733,4 +1765,4 @@ interface WebSocketHandlers {
1733
1765
  interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog'> {
1734
1766
  }
1735
1767
 
1736
- export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyContext, SpyInstance, SpyInstanceFn, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TransformResultWithSource, UncheckedSnapshot, UserConfig, UserConsoleLog, Vitest, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerGlobalState, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, createExpect, describe, expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest, withCallback };
1768
+ export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyContext, SpyInstance, SpyInstanceFn, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TransformResultWithSource, UncheckedSnapshot, UserConfig, UserConsoleLog, Vitest, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerGlobalState, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, createExpect, describe, globalExpect as expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest, withCallback };
package/dist/index.mjs CHANGED
@@ -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.6a3c6576.mjs';
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.ce7f4b92.mjs';
2
2
  export { assert, default as chai, should } from 'chai';
3
3
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
4
- import './chunk-runtime-rpc.44043bb4.mjs';
5
- import './chunk-utils-global.624991bc.mjs';
4
+ import './chunk-runtime-rpc.5e78af38.mjs';
5
+ import './chunk-utils-global.79a8b1cc.mjs';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
9
9
  import 'fs';
10
- import './chunk-utils-source-map.4408ba82.mjs';
10
+ import './chunk-utils-source-map.2556cba8.mjs';
11
11
  import './chunk-integrations-spy.674b628e.mjs';
12
12
  import 'tinyspy';
13
13
  import 'util';
package/dist/node.d.ts CHANGED
@@ -798,6 +798,10 @@ interface InlineConfig {
798
798
  * diff output length
799
799
  */
800
800
  outputTruncateLength?: number;
801
+ /**
802
+ * number of diff output lines
803
+ */
804
+ outputDiffLines?: number;
801
805
  /**
802
806
  * Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
803
807
  * Also definable individually per reporter by using an object instead.
@@ -967,6 +971,22 @@ interface InlineConfig {
967
971
  * Return `false` to ignore the log.
968
972
  */
969
973
  onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
974
+ /**
975
+ * Indicates if CSS files should be processed.
976
+ *
977
+ * When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
978
+ *
979
+ * @default { include: [/\.module\./] }
980
+ */
981
+ css?: boolean | {
982
+ include?: RegExp | RegExp[];
983
+ exclude?: RegExp | RegExp[];
984
+ };
985
+ /**
986
+ * A number of tests that are allowed to run at the same time marked with `test.concurrent`.
987
+ * @default 5
988
+ */
989
+ maxConcurrency?: number;
970
990
  }
971
991
  interface UserConfig extends InlineConfig {
972
992
  /**
@@ -998,8 +1018,15 @@ interface UserConfig extends InlineConfig {
998
1018
  * @default false
999
1019
  */
1000
1020
  changed?: boolean | string;
1021
+ /**
1022
+ * Test suite shard to execute in a format of <index>/<count>.
1023
+ * Will divide tests into a `count` numbers, and run only the `indexed` part.
1024
+ * Cannot be used with enabled watch.
1025
+ * @example --shard=2/3
1026
+ */
1027
+ shard?: string;
1001
1028
  }
1002
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath'> {
1029
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard'> {
1003
1030
  base?: string;
1004
1031
  config?: string;
1005
1032
  filters?: string[];
@@ -1010,6 +1037,10 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
1010
1037
  reporters: (Reporter | BuiltinReporters)[];
1011
1038
  defines: Record<string, any>;
1012
1039
  api?: ApiConfig;
1040
+ shard?: {
1041
+ index: number;
1042
+ count: number;
1043
+ };
1013
1044
  }
1014
1045
 
1015
1046
  declare type VitestInlineConfig = InlineConfig;
package/dist/node.mjs CHANGED
@@ -1,6 +1,6 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.d492e389.mjs';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.7cf95199.mjs';
3
- import './chunk-utils-global.624991bc.mjs';
1
+ export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.105bc106.mjs';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.2f3cbfe5.mjs';
3
+ import './chunk-utils-global.79a8b1cc.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
@@ -8,24 +8,25 @@ import 'vite';
8
8
  import 'url';
9
9
  import 'process';
10
10
  import 'fs';
11
- import './chunk-constants.41584d81.mjs';
11
+ import './chunk-defaults.dc6dc23d.mjs';
12
+ import 'module';
13
+ import './chunk-constants.7b9cfc82.mjs';
12
14
  import 'readline';
13
15
  import 'os';
14
16
  import 'util';
15
17
  import 'stream';
16
18
  import 'events';
17
19
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
18
- import './chunk-vite-node-utils.d6687931.mjs';
19
- import 'module';
20
+ import './chunk-vite-node-utils.c0a0e1b3.mjs';
20
21
  import 'vm';
21
22
  import 'assert';
22
23
  import 'debug';
23
- import './chunk-defaults.a820faeb.mjs';
24
24
  import 'worker_threads';
25
+ import 'crypto';
25
26
  import 'tinypool';
26
27
  import 'perf_hooks';
27
- import './chunk-utils-source-map.4408ba82.mjs';
28
- import './vendor-index.a2a385d8.mjs';
28
+ import './chunk-utils-source-map.2556cba8.mjs';
29
+ import './vendor-index.e5dc6622.mjs';
29
30
  import 'child_process';
30
31
  import 'buffer';
31
32
  import './chunk-magic-string.efe26975.mjs';
@@ -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.624991bc.mjs';
2
+ import { t as isNode, a as getWorkerState, h as safeClearTimeout, f as safeSetTimeout, C as toArray, N as deepClone, L as getType, q as relative, O as partitionSuiteChildren, P as hasTests, v as hasFailed, e as getFullName, r as resetModules } from './chunk-utils-global.79a8b1cc.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.6a3c6576.mjs';
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 globalExpect, 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, G as GLOBAL_EXPECT, z as getFn, A as getState } from './chunk-runtime-chain.ce7f4b92.mjs';
5
5
  import chai, { assert, should, util } from 'chai';
6
- import { r as rpc } from './chunk-runtime-rpc.44043bb4.mjs';
7
- import { t as takeCoverage } from './chunk-defaults.a820faeb.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
7
+ import { t as takeCoverage, p as pLimit } from './chunk-defaults.dc6dc23d.mjs';
8
8
  import { format } from 'util';
9
- import { s as stringify } from './chunk-utils-source-map.4408ba82.mjs';
9
+ import { s as stringify } from './chunk-utils-source-map.2556cba8.mjs';
10
10
 
11
11
  var index = /*#__PURE__*/Object.freeze({
12
12
  __proto__: null,
@@ -25,7 +25,7 @@ var index = /*#__PURE__*/Object.freeze({
25
25
  should: should,
26
26
  createExpect: createExpect,
27
27
  chai: chai,
28
- expect: expect,
28
+ expect: globalExpect,
29
29
  vitest: vitest,
30
30
  vi: vi,
31
31
  getRunningMode: getRunningMode,
@@ -201,7 +201,9 @@ const LIVING_KEYS = [
201
201
  "Headers",
202
202
  "AbortController",
203
203
  "AbortSignal",
204
- "Image"
204
+ "Image",
205
+ "Audio",
206
+ "Option"
205
207
  ];
206
208
  const OTHER_KEYS = [
207
209
  "addEventListener",
@@ -273,7 +275,7 @@ const skipKeys = [
273
275
  ];
274
276
  function getWindowKeys(global, win) {
275
277
  const keys = new Set(KEYS.concat(Object.getOwnPropertyNames(win)).filter((k) => {
276
- if (k.startsWith("_") || skipKeys.includes(k))
278
+ if (skipKeys.includes(k))
277
279
  return false;
278
280
  if (k in global)
279
281
  return allowRewrite.includes(k);
@@ -284,7 +286,7 @@ function getWindowKeys(global, win) {
284
286
  function isClassLikeName(name) {
285
287
  return name[0] === name[0].toUpperCase();
286
288
  }
287
- function populateGlobal(global, win, options) {
289
+ function populateGlobal(global, win, options = {}) {
288
290
  const { bindFunctions = false } = options;
289
291
  const keys = getWindowKeys(global, win);
290
292
  const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
@@ -308,6 +310,7 @@ function populateGlobal(global, win, options) {
308
310
  global.window = global;
309
311
  global.self = global;
310
312
  global.top = global;
313
+ global.parent = global;
311
314
  if (global.global)
312
315
  global.global = global;
313
316
  skipKeys.forEach((k) => keys.add(k));
@@ -435,7 +438,7 @@ async function setupGlobalEnv(config) {
435
438
  if (isNode)
436
439
  await setupConsoleLogSpy();
437
440
  if (config.globals)
438
- (await import('./chunk-integrations-globals.f0c5e97f.mjs')).registerApiGlobally();
441
+ (await import('./chunk-integrations-globals.df0878f4.mjs')).registerApiGlobally();
439
442
  }
440
443
  function setupDefines(defines) {
441
444
  for (const key in defines)
@@ -580,24 +583,24 @@ function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
580
583
  if (seen.has(val))
581
584
  return seen.get(val);
582
585
  if (Array.isArray(val)) {
583
- const clone2 = new Array(val.length);
584
- seen.set(val, clone2);
586
+ const clone = new Array(val.length);
587
+ seen.set(val, clone);
585
588
  val.forEach((e, i) => {
586
- clone2[i] = serializeError(e, seen);
589
+ clone[i] = serializeError(e, seen);
587
590
  });
588
- return clone2;
591
+ return clone;
589
592
  } else {
590
- const clone2 = /* @__PURE__ */ Object.create(null);
591
- seen.set(val, clone2);
593
+ const clone = /* @__PURE__ */ Object.create(null);
594
+ seen.set(val, clone);
592
595
  let obj = val;
593
596
  while (obj && obj !== OBJECT_PROTO) {
594
597
  Object.getOwnPropertyNames(obj).forEach((key) => {
595
- if (!(key in clone2))
596
- clone2[key] = serializeError(obj[key], seen);
598
+ if (!(key in clone))
599
+ clone[key] = serializeError(obj[key], seen);
597
600
  });
598
601
  obj = Object.getPrototypeOf(obj);
599
602
  }
600
- return clone2;
603
+ return clone;
601
604
  }
602
605
  }
603
606
  function normalizeErrorMessage(message) {
@@ -610,8 +613,8 @@ function processError(err) {
610
613
  err.stackStr = String(err.stack);
611
614
  if (err.name)
612
615
  err.nameStr = String(err.name);
613
- const clonedActual = clone(err.actual);
614
- const clonedExpected = clone(err.expected);
616
+ const clonedActual = deepClone(err.actual);
617
+ const clonedExpected = deepClone(err.expected);
615
618
  const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected);
616
619
  err.actual = replacedActual;
617
620
  err.expected = replacedExpected;
@@ -642,9 +645,13 @@ function isReplaceable(obj1, obj2) {
642
645
  const obj2Type = getType(obj2);
643
646
  return obj1Type === obj2Type && obj1Type === "Object";
644
647
  }
645
- function replaceAsymmetricMatcher(actual, expected) {
648
+ function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE__ */ new WeakMap(), expectedReplaced = /* @__PURE__ */ new WeakMap()) {
646
649
  if (!isReplaceable(actual, expected))
647
650
  return { replacedActual: actual, replacedExpected: expected };
651
+ if (actualReplaced.has(actual) || expectedReplaced.has(expected))
652
+ return { replacedActual: actual, replacedExpected: expected };
653
+ actualReplaced.set(actual, true);
654
+ expectedReplaced.set(expected, true);
648
655
  util.getOwnEnumerableProperties(expected).forEach((key) => {
649
656
  const expectedValue = expected[key];
650
657
  const actualValue = actual[key];
@@ -655,7 +662,7 @@ function replaceAsymmetricMatcher(actual, expected) {
655
662
  if (actualValue.asymmetricMatch(expectedValue))
656
663
  expected[key] = actualValue;
657
664
  } else if (isReplaceable(actualValue, expectedValue)) {
658
- const replaced = replaceAsymmetricMatcher(actualValue, expectedValue);
665
+ const replaced = replaceAsymmetricMatcher(actualValue, expectedValue, actualReplaced, expectedReplaced);
659
666
  actual[key] = replaced.replacedActual;
660
667
  expected[key] = replaced.replacedExpected;
661
668
  }
@@ -878,9 +885,15 @@ async function runTest(test) {
878
885
  expectedAssertionsNumberErrorGen: null,
879
886
  testPath: (_b = test.suite.file) == null ? void 0 : _b.filepath,
880
887
  currentTestName: getFullName(test)
881
- });
888
+ }, globalThis[GLOBAL_EXPECT]);
882
889
  await getFn(test)();
883
- const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberErrorGen, isExpectingAssertions, isExpectingAssertionsError } = getState();
890
+ const {
891
+ assertionCalls,
892
+ expectedAssertionsNumber,
893
+ expectedAssertionsNumberErrorGen,
894
+ isExpectingAssertions,
895
+ isExpectingAssertionsError
896
+ } = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
884
897
  if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
885
898
  throw expectedAssertionsNumberErrorGen();
886
899
  if (isExpectingAssertions === true && assertionCalls === 0)
@@ -935,6 +948,7 @@ async function runSuite(suite) {
935
948
  startTime: start
936
949
  };
937
950
  updateTask(suite);
951
+ const workerState = getWorkerState();
938
952
  if (suite.mode === "skip") {
939
953
  suite.result.state = "skip";
940
954
  } else if (suite.mode === "todo") {
@@ -944,7 +958,8 @@ async function runSuite(suite) {
944
958
  const beforeAllCleanups = await callSuiteHook(suite, suite, "beforeAll", [suite]);
945
959
  for (const tasksGroup of partitionSuiteChildren(suite)) {
946
960
  if (tasksGroup[0].concurrent === true) {
947
- await Promise.all(tasksGroup.map((c) => runSuiteChild(c)));
961
+ const mutex = pLimit(workerState.config.maxConcurrency);
962
+ await Promise.all(tasksGroup.map((c) => mutex(() => runSuiteChild(c))));
948
963
  } else {
949
964
  for (const c of tasksGroup)
950
965
  await runSuiteChild(c);
@@ -958,7 +973,6 @@ async function runSuite(suite) {
958
973
  }
959
974
  }
960
975
  suite.result.duration = now() - start;
961
- const workerState = getWorkerState();
962
976
  if (workerState.config.logHeapUsage)
963
977
  suite.result.heap = process.memoryUsage().heapUsed;
964
978
  if (suite.mode === "run") {
package/dist/worker.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { l as resolve, a as getWorkerState } from './chunk-utils-global.624991bc.mjs';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.d6687931.mjs';
3
- import { d as distDir } from './chunk-constants.41584d81.mjs';
4
- import { e as executeInViteNode } from './chunk-runtime-mocker.7cf95199.mjs';
5
- import { r as rpc } from './chunk-runtime-rpc.44043bb4.mjs';
1
+ import { m as resolve, a as getWorkerState } from './chunk-utils-global.79a8b1cc.mjs';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.c0a0e1b3.mjs';
3
+ import { d as distDir } from './chunk-constants.7b9cfc82.mjs';
4
+ import { e as executeInViteNode } from './chunk-runtime-mocker.2f3cbfe5.mjs';
5
+ import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
@@ -55,8 +55,9 @@ async function startViteNode(ctx) {
55
55
  function init(ctx) {
56
56
  if (typeof __vitest_worker__ !== "undefined" && ctx.config.threads && ctx.config.isolate)
57
57
  throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
58
- const { config, port, id } = ctx;
59
- process.env.VITEST_WORKER_ID = String(id);
58
+ const { config, port, workerId, poolId } = ctx;
59
+ process.env.VITEST_WORKER_ID = String(workerId);
60
+ process.env.VITEST_POOL_ID = String(poolId);
60
61
  globalThis.__vitest_worker__ = {
61
62
  ctx,
62
63
  moduleCache,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -79,12 +79,13 @@
79
79
  "dependencies": {
80
80
  "@types/chai": "^4.3.1",
81
81
  "@types/chai-subset": "^1.3.3",
82
+ "@types/node": "*",
82
83
  "chai": "^4.3.6",
83
84
  "debug": "^4.3.4",
84
85
  "local-pkg": "^0.4.1",
85
86
  "tinypool": "^0.1.3",
86
87
  "tinyspy": "^0.3.2",
87
- "vite": "^2.9.9"
88
+ "vite": "^2.9.12"
88
89
  },
89
90
  "devDependencies": {
90
91
  "@antfu/install-pkg": "^0.1.0",
@@ -93,10 +94,9 @@
93
94
  "@types/jsdom": "^16.2.14",
94
95
  "@types/micromatch": "^4.0.2",
95
96
  "@types/natural-compare": "^1.4.1",
96
- "@types/node": "^17.0.35",
97
97
  "@types/prompts": "^2.4.0",
98
98
  "@types/sinonjs__fake-timers": "^8.1.2",
99
- "@vitest/ui": "0.14.1",
99
+ "@vitest/ui": "0.15.1",
100
100
  "birpc": "^0.2.3",
101
101
  "c8": "^7.11.3",
102
102
  "cac": "^6.7.12",
@@ -114,17 +114,18 @@
114
114
  "micromatch": "^4.0.5",
115
115
  "mlly": "^0.5.2",
116
116
  "natural-compare": "^1.4.0",
117
+ "p-limit": "^4.0.0",
117
118
  "pathe": "^0.2.0",
118
119
  "picocolors": "^1.0.0",
119
120
  "pkg-types": "^0.3.2",
120
121
  "pretty-format": "^27.5.1",
121
122
  "prompts": "^2.4.2",
122
- "rollup": "^2.75.3",
123
+ "rollup": "^2.75.6",
123
124
  "source-map-js": "^1.0.2",
124
125
  "strip-ansi": "^7.0.1",
125
- "typescript": "^4.7.2",
126
- "vite-node": "0.14.1",
127
- "ws": "^8.7.0"
126
+ "typescript": "^4.7.3",
127
+ "vite-node": "0.15.1",
128
+ "ws": "^8.8.0"
128
129
  },
129
130
  "scripts": {
130
131
  "build": "rimraf dist && rollup -c",