vitest 0.11.0 → 0.12.2
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/dist/{chunk-api-setup.87a943bf.js → chunk-api-setup.ed61899f.js} +1 -1
- package/dist/{chunk-defaults.23b3ae8a.js → chunk-defaults.ecb46baf.js} +15 -1
- package/dist/{chunk-integrations-globals.1ce15dfd.js → chunk-integrations-globals.60fc66ef.js} +3 -3
- package/dist/{chunk-runtime-chain.8a313ffb.js → chunk-runtime-chain.221b8dcb.js} +107 -83
- package/dist/{chunk-runtime-mocker.ee72d19a.js → chunk-runtime-mocker.acd615bd.js} +5 -2
- package/dist/{chunk-vite-node-externalize.d6642729.js → chunk-vite-node-externalize.2c1fbe22.js} +6 -6
- package/dist/{chunk-vite-node-utils.20782527.js → chunk-vite-node-utils.1536f168.js} +2 -7
- package/dist/cli.js +3 -3
- package/dist/config.cjs +15 -1
- package/dist/config.d.ts +67 -0
- package/dist/config.js +15 -1
- package/dist/entry.js +3 -3
- package/dist/index.d.ts +87 -13
- package/dist/index.js +1 -1
- package/dist/node.d.ts +86 -12
- package/dist/node.js +4 -4
- package/dist/{vendor-entry.1b0b46f1.js → vendor-entry.3adaf0b2.js} +116 -77
- package/dist/worker.js +3 -4
- package/package.json +4 -4
package/dist/entry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { r as run } from './vendor-entry.
|
|
1
|
+
export { r as run } from './vendor-entry.3adaf0b2.js';
|
|
2
2
|
import 'fs';
|
|
3
3
|
import './chunk-utils-global.a5a8641f.js';
|
|
4
4
|
import 'tty';
|
|
@@ -6,7 +6,7 @@ import 'local-pkg';
|
|
|
6
6
|
import 'path';
|
|
7
7
|
import 'console';
|
|
8
8
|
import 'stream';
|
|
9
|
-
import './chunk-runtime-chain.
|
|
9
|
+
import './chunk-runtime-chain.221b8dcb.js';
|
|
10
10
|
import 'chai';
|
|
11
11
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
12
12
|
import './chunk-runtime-rpc.63398738.js';
|
|
@@ -14,7 +14,7 @@ import './chunk-utils-timers.f25e8f44.js';
|
|
|
14
14
|
import './chunk-integrations-spy.bee66426.js';
|
|
15
15
|
import 'tinyspy';
|
|
16
16
|
import 'util';
|
|
17
|
-
import './chunk-defaults.
|
|
17
|
+
import './chunk-defaults.ecb46baf.js';
|
|
18
18
|
import 'module';
|
|
19
19
|
import 'url';
|
|
20
20
|
import 'crypto';
|
package/dist/index.d.ts
CHANGED
|
@@ -196,6 +196,72 @@ interface RawMatcherFn<T extends MatcherState = MatcherState> {
|
|
|
196
196
|
}
|
|
197
197
|
declare type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
|
|
198
198
|
|
|
199
|
+
// Type definitions for @sinonjs/fake-timers 8.1
|
|
200
|
+
// Project: https://github.com/sinonjs/fake-timers
|
|
201
|
+
// Definitions by: Wim Looman <https://github.com/Nemo157>
|
|
202
|
+
// Rogier Schouten <https://github.com/rogierschouten>
|
|
203
|
+
// Yishai Zehavi <https://github.com/zyishai>
|
|
204
|
+
// Remco Haszing <https://github.com/remcohaszing>
|
|
205
|
+
// Jaden Simon <https://github.com/JadenSimon>
|
|
206
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
207
|
+
// TypeScript Version: 2.3
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Names of clock methods that may be faked by install.
|
|
211
|
+
*/
|
|
212
|
+
type FakeMethod =
|
|
213
|
+
| 'setTimeout'
|
|
214
|
+
| 'clearTimeout'
|
|
215
|
+
| 'setImmediate'
|
|
216
|
+
| 'clearImmediate'
|
|
217
|
+
| 'setInterval'
|
|
218
|
+
| 'clearInterval'
|
|
219
|
+
| 'Date'
|
|
220
|
+
| 'nextTick'
|
|
221
|
+
| 'hrtime'
|
|
222
|
+
| 'requestAnimationFrame'
|
|
223
|
+
| 'cancelAnimationFrame'
|
|
224
|
+
| 'requestIdleCallback'
|
|
225
|
+
| 'cancelIdleCallback'
|
|
226
|
+
| 'performance'
|
|
227
|
+
| 'queueMicrotask';
|
|
228
|
+
|
|
229
|
+
interface FakeTimerInstallOpts {
|
|
230
|
+
/**
|
|
231
|
+
* Installs fake timers with the specified unix epoch (default: 0)
|
|
232
|
+
*/
|
|
233
|
+
now?: number | Date | undefined;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
|
|
237
|
+
* For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
|
|
238
|
+
*/
|
|
239
|
+
toFake?: FakeMethod[] | undefined;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The maximum number of timers that will be run when calling runAll() (default: 1000)
|
|
243
|
+
*/
|
|
244
|
+
loopLimit?: number | undefined;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
|
|
248
|
+
* 20ms for every 20ms change in the real system time) (default: false)
|
|
249
|
+
*/
|
|
250
|
+
shouldAdvanceTime?: boolean | undefined;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
|
|
254
|
+
* in the real system time (default: 20)
|
|
255
|
+
*/
|
|
256
|
+
advanceTimeDelta?: number | undefined;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
|
|
260
|
+
* default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
|
|
261
|
+
*/
|
|
262
|
+
shouldClearNativeTimers?: boolean | undefined;
|
|
263
|
+
}
|
|
264
|
+
|
|
199
265
|
declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
|
|
200
266
|
normalizePath(fsPath: string): string;
|
|
201
267
|
set(fsPath: string, mod: Partial<ModuleCache$1>): this;
|
|
@@ -333,7 +399,6 @@ declare class SnapshotManager {
|
|
|
333
399
|
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
|
334
400
|
interface WorkerPool {
|
|
335
401
|
runTests: RunWithFiles;
|
|
336
|
-
collectTests: RunWithFiles;
|
|
337
402
|
close: () => Promise<void>;
|
|
338
403
|
}
|
|
339
404
|
|
|
@@ -758,6 +823,7 @@ declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
|
758
823
|
interface Suite extends TaskBase {
|
|
759
824
|
type: 'suite';
|
|
760
825
|
tasks: Task[];
|
|
826
|
+
filepath?: string;
|
|
761
827
|
}
|
|
762
828
|
interface File extends Suite {
|
|
763
829
|
filepath: string;
|
|
@@ -810,8 +876,8 @@ declare type SuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'onl
|
|
|
810
876
|
};
|
|
811
877
|
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return | void>;
|
|
812
878
|
interface SuiteHooks {
|
|
813
|
-
beforeAll: HookListener<[Suite], () => Awaitable<void>>[];
|
|
814
|
-
afterAll: HookListener<[Suite]>[];
|
|
879
|
+
beforeAll: HookListener<[Suite | File], () => Awaitable<void>>[];
|
|
880
|
+
afterAll: HookListener<[Suite | File]>[];
|
|
815
881
|
beforeEach: HookListener<[TestContext, Suite], () => Awaitable<void>>[];
|
|
816
882
|
afterEach: HookListener<[TestContext, Suite]>[];
|
|
817
883
|
}
|
|
@@ -1069,7 +1135,7 @@ interface InlineConfig {
|
|
|
1069
1135
|
/**
|
|
1070
1136
|
* Pattern of file paths to be ignore from triggering watch rerun
|
|
1071
1137
|
*
|
|
1072
|
-
* @default [
|
|
1138
|
+
* @default [/\/node_modules\//, /\/dist\//]
|
|
1073
1139
|
*/
|
|
1074
1140
|
watchIgnore?: (string | RegExp)[];
|
|
1075
1141
|
/**
|
|
@@ -1154,10 +1220,26 @@ interface InlineConfig {
|
|
|
1154
1220
|
* Resolve custom snapshot path
|
|
1155
1221
|
*/
|
|
1156
1222
|
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
1223
|
+
/**
|
|
1224
|
+
* Pass with no tests
|
|
1225
|
+
*/
|
|
1226
|
+
passWithNoTests?: boolean;
|
|
1227
|
+
/**
|
|
1228
|
+
* Allow tests and suites that are marked as only
|
|
1229
|
+
*/
|
|
1230
|
+
allowOnly?: boolean;
|
|
1157
1231
|
/**
|
|
1158
1232
|
* Show heap usage after each test. Usefull for debugging memory leaks.
|
|
1159
1233
|
*/
|
|
1160
1234
|
logHeapUsage?: boolean;
|
|
1235
|
+
/**
|
|
1236
|
+
* Custom environment variables assigned to `process.env` before running tests.
|
|
1237
|
+
*/
|
|
1238
|
+
env?: Record<string, string>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Options for @sinon/fake-timers
|
|
1241
|
+
*/
|
|
1242
|
+
fakeTimers?: FakeTimerInstallOpts;
|
|
1161
1243
|
}
|
|
1162
1244
|
interface UserConfig extends InlineConfig {
|
|
1163
1245
|
/**
|
|
@@ -1174,14 +1256,6 @@ interface UserConfig extends InlineConfig {
|
|
|
1174
1256
|
* Use happy-dom
|
|
1175
1257
|
*/
|
|
1176
1258
|
dom?: boolean;
|
|
1177
|
-
/**
|
|
1178
|
-
* Pass with no tests
|
|
1179
|
-
*/
|
|
1180
|
-
passWithNoTests?: boolean;
|
|
1181
|
-
/**
|
|
1182
|
-
* Allow tests and suites that are marked as only
|
|
1183
|
-
*/
|
|
1184
|
-
allowOnly?: boolean;
|
|
1185
1259
|
/**
|
|
1186
1260
|
* Run tests that cover a list of source files
|
|
1187
1261
|
*/
|
|
@@ -1380,7 +1454,7 @@ declare class VitestUtils {
|
|
|
1380
1454
|
private _mockedDate;
|
|
1381
1455
|
private _mocker;
|
|
1382
1456
|
constructor();
|
|
1383
|
-
useFakeTimers(): this;
|
|
1457
|
+
useFakeTimers(config?: FakeTimerInstallOpts): this;
|
|
1384
1458
|
useRealTimers(): this;
|
|
1385
1459
|
runOnlyPendingTimers(): this;
|
|
1386
1460
|
runAllTimers(): this;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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.
|
|
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.221b8dcb.js';
|
|
2
2
|
export { assert, default as chai, should } from 'chai';
|
|
3
3
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
4
4
|
import './chunk-runtime-rpc.63398738.js';
|
package/dist/node.d.ts
CHANGED
|
@@ -211,6 +211,72 @@ declare type OldPlugin = {
|
|
|
211
211
|
declare type Plugin = NewPlugin | OldPlugin;
|
|
212
212
|
declare type Plugins = Array<Plugin>;
|
|
213
213
|
|
|
214
|
+
// Type definitions for @sinonjs/fake-timers 8.1
|
|
215
|
+
// Project: https://github.com/sinonjs/fake-timers
|
|
216
|
+
// Definitions by: Wim Looman <https://github.com/Nemo157>
|
|
217
|
+
// Rogier Schouten <https://github.com/rogierschouten>
|
|
218
|
+
// Yishai Zehavi <https://github.com/zyishai>
|
|
219
|
+
// Remco Haszing <https://github.com/remcohaszing>
|
|
220
|
+
// Jaden Simon <https://github.com/JadenSimon>
|
|
221
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
222
|
+
// TypeScript Version: 2.3
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Names of clock methods that may be faked by install.
|
|
226
|
+
*/
|
|
227
|
+
type FakeMethod =
|
|
228
|
+
| 'setTimeout'
|
|
229
|
+
| 'clearTimeout'
|
|
230
|
+
| 'setImmediate'
|
|
231
|
+
| 'clearImmediate'
|
|
232
|
+
| 'setInterval'
|
|
233
|
+
| 'clearInterval'
|
|
234
|
+
| 'Date'
|
|
235
|
+
| 'nextTick'
|
|
236
|
+
| 'hrtime'
|
|
237
|
+
| 'requestAnimationFrame'
|
|
238
|
+
| 'cancelAnimationFrame'
|
|
239
|
+
| 'requestIdleCallback'
|
|
240
|
+
| 'cancelIdleCallback'
|
|
241
|
+
| 'performance'
|
|
242
|
+
| 'queueMicrotask';
|
|
243
|
+
|
|
244
|
+
interface FakeTimerInstallOpts {
|
|
245
|
+
/**
|
|
246
|
+
* Installs fake timers with the specified unix epoch (default: 0)
|
|
247
|
+
*/
|
|
248
|
+
now?: number | Date | undefined;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
|
|
252
|
+
* For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
|
|
253
|
+
*/
|
|
254
|
+
toFake?: FakeMethod[] | undefined;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The maximum number of timers that will be run when calling runAll() (default: 1000)
|
|
258
|
+
*/
|
|
259
|
+
loopLimit?: number | undefined;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
|
|
263
|
+
* 20ms for every 20ms change in the real system time) (default: false)
|
|
264
|
+
*/
|
|
265
|
+
shouldAdvanceTime?: boolean | undefined;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
|
|
269
|
+
* in the real system time (default: 20)
|
|
270
|
+
*/
|
|
271
|
+
advanceTimeDelta?: number | undefined;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
|
|
275
|
+
* default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
|
|
276
|
+
*/
|
|
277
|
+
shouldClearNativeTimers?: boolean | undefined;
|
|
278
|
+
}
|
|
279
|
+
|
|
214
280
|
declare abstract class BaseReporter implements Reporter {
|
|
215
281
|
start: number;
|
|
216
282
|
end: number;
|
|
@@ -521,6 +587,7 @@ declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
|
521
587
|
interface Suite extends TaskBase {
|
|
522
588
|
type: 'suite';
|
|
523
589
|
tasks: Task[];
|
|
590
|
+
filepath?: string;
|
|
524
591
|
}
|
|
525
592
|
interface File extends Suite {
|
|
526
593
|
filepath: string;
|
|
@@ -536,8 +603,8 @@ interface Test<ExtraContext = {}> extends TaskBase {
|
|
|
536
603
|
declare type Task = Test | Suite | File;
|
|
537
604
|
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return | void>;
|
|
538
605
|
interface SuiteHooks {
|
|
539
|
-
beforeAll: HookListener<[Suite], () => Awaitable<void>>[];
|
|
540
|
-
afterAll: HookListener<[Suite]>[];
|
|
606
|
+
beforeAll: HookListener<[Suite | File], () => Awaitable<void>>[];
|
|
607
|
+
afterAll: HookListener<[Suite | File]>[];
|
|
541
608
|
beforeEach: HookListener<[TestContext, Suite], () => Awaitable<void>>[];
|
|
542
609
|
afterEach: HookListener<[TestContext, Suite]>[];
|
|
543
610
|
}
|
|
@@ -770,7 +837,7 @@ interface InlineConfig {
|
|
|
770
837
|
/**
|
|
771
838
|
* Pattern of file paths to be ignore from triggering watch rerun
|
|
772
839
|
*
|
|
773
|
-
* @default [
|
|
840
|
+
* @default [/\/node_modules\//, /\/dist\//]
|
|
774
841
|
*/
|
|
775
842
|
watchIgnore?: (string | RegExp)[];
|
|
776
843
|
/**
|
|
@@ -855,10 +922,26 @@ interface InlineConfig {
|
|
|
855
922
|
* Resolve custom snapshot path
|
|
856
923
|
*/
|
|
857
924
|
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
925
|
+
/**
|
|
926
|
+
* Pass with no tests
|
|
927
|
+
*/
|
|
928
|
+
passWithNoTests?: boolean;
|
|
929
|
+
/**
|
|
930
|
+
* Allow tests and suites that are marked as only
|
|
931
|
+
*/
|
|
932
|
+
allowOnly?: boolean;
|
|
858
933
|
/**
|
|
859
934
|
* Show heap usage after each test. Usefull for debugging memory leaks.
|
|
860
935
|
*/
|
|
861
936
|
logHeapUsage?: boolean;
|
|
937
|
+
/**
|
|
938
|
+
* Custom environment variables assigned to `process.env` before running tests.
|
|
939
|
+
*/
|
|
940
|
+
env?: Record<string, string>;
|
|
941
|
+
/**
|
|
942
|
+
* Options for @sinon/fake-timers
|
|
943
|
+
*/
|
|
944
|
+
fakeTimers?: FakeTimerInstallOpts;
|
|
862
945
|
}
|
|
863
946
|
interface UserConfig extends InlineConfig {
|
|
864
947
|
/**
|
|
@@ -875,14 +958,6 @@ interface UserConfig extends InlineConfig {
|
|
|
875
958
|
* Use happy-dom
|
|
876
959
|
*/
|
|
877
960
|
dom?: boolean;
|
|
878
|
-
/**
|
|
879
|
-
* Pass with no tests
|
|
880
|
-
*/
|
|
881
|
-
passWithNoTests?: boolean;
|
|
882
|
-
/**
|
|
883
|
-
* Allow tests and suites that are marked as only
|
|
884
|
-
*/
|
|
885
|
-
allowOnly?: boolean;
|
|
886
961
|
/**
|
|
887
962
|
* Run tests that cover a list of source files
|
|
888
963
|
*/
|
|
@@ -927,7 +1002,6 @@ declare class SnapshotManager {
|
|
|
927
1002
|
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
|
928
1003
|
interface WorkerPool {
|
|
929
1004
|
runTests: RunWithFiles;
|
|
930
|
-
collectTests: RunWithFiles;
|
|
931
1005
|
close: () => Promise<void>;
|
|
932
1006
|
}
|
|
933
1007
|
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
1
|
+
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.2c1fbe22.js';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.acd615bd.js';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'path';
|
|
5
5
|
import 'child_process';
|
|
@@ -19,10 +19,10 @@ import 'local-pkg';
|
|
|
19
19
|
import 'vite';
|
|
20
20
|
import './chunk-constants.0567483c.js';
|
|
21
21
|
import 'readline';
|
|
22
|
-
import './chunk-vite-node-utils.
|
|
22
|
+
import './chunk-vite-node-utils.1536f168.js';
|
|
23
23
|
import 'module';
|
|
24
24
|
import 'vm';
|
|
25
|
-
import './chunk-defaults.
|
|
25
|
+
import './chunk-defaults.ecb46baf.js';
|
|
26
26
|
import 'worker_threads';
|
|
27
27
|
import 'tinypool';
|
|
28
28
|
import 'perf_hooks';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { a as getWorkerState, t as toArray, G as clone, E as getType, l as relative,
|
|
2
|
+
import { a as getWorkerState, t as toArray, G as clone, E as getType, l as relative, H as partitionSuiteChildren, I as hasTests, q as hasFailed, o as getFullName, r as resetModules } from './chunk-utils-global.a5a8641f.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
|
-
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.
|
|
6
|
+
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.221b8dcb.js';
|
|
7
7
|
import chai, { assert, should, util } from 'chai';
|
|
8
8
|
import { r as rpc } from './chunk-runtime-rpc.63398738.js';
|
|
9
9
|
import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.f25e8f44.js';
|
|
10
|
-
import { t as takeCoverage } from './chunk-defaults.
|
|
10
|
+
import { t as takeCoverage } from './chunk-defaults.ecb46baf.js';
|
|
11
11
|
import { createHash } from 'crypto';
|
|
12
12
|
import { format } from 'util';
|
|
13
13
|
|
|
@@ -270,7 +270,9 @@ const allowRewrite = [
|
|
|
270
270
|
];
|
|
271
271
|
const skipKeys = [
|
|
272
272
|
"window",
|
|
273
|
-
"self"
|
|
273
|
+
"self",
|
|
274
|
+
"top",
|
|
275
|
+
"parent"
|
|
274
276
|
];
|
|
275
277
|
function getWindowKeys(global, win) {
|
|
276
278
|
const keys = new Set(KEYS.concat(Object.getOwnPropertyNames(win)).filter((k) => {
|
|
@@ -282,14 +284,18 @@ function getWindowKeys(global, win) {
|
|
|
282
284
|
}));
|
|
283
285
|
return keys;
|
|
284
286
|
}
|
|
285
|
-
function populateGlobal(global, win) {
|
|
287
|
+
function populateGlobal(global, win, options = {}) {
|
|
288
|
+
const { bindFunctions = false } = options;
|
|
286
289
|
const keys = getWindowKeys(global, win);
|
|
287
290
|
const overrideObject = /* @__PURE__ */ new Map();
|
|
288
291
|
for (const key of keys) {
|
|
292
|
+
const shouldBind = bindFunctions && typeof win[key] === "function";
|
|
289
293
|
Object.defineProperty(global, key, {
|
|
290
294
|
get() {
|
|
291
295
|
if (overrideObject.has(key))
|
|
292
296
|
return overrideObject.get(key);
|
|
297
|
+
if (shouldBind)
|
|
298
|
+
return win[key].bind(win);
|
|
293
299
|
return win[key];
|
|
294
300
|
},
|
|
295
301
|
set(v) {
|
|
@@ -298,50 +304,50 @@ function populateGlobal(global, win) {
|
|
|
298
304
|
configurable: true
|
|
299
305
|
});
|
|
300
306
|
}
|
|
301
|
-
const globalKeys = /* @__PURE__ */ new Set(["window", "self", "
|
|
307
|
+
const globalKeys = /* @__PURE__ */ new Set(["window", "self", "top", "parent"]);
|
|
308
|
+
const globalProxy = new Proxy(win.window, {
|
|
309
|
+
get(target, p, receiver) {
|
|
310
|
+
if (overrideObject.has(p))
|
|
311
|
+
return overrideObject.get(p);
|
|
312
|
+
return Reflect.get(target, p, receiver);
|
|
313
|
+
},
|
|
314
|
+
set(target, p, value, receiver) {
|
|
315
|
+
try {
|
|
316
|
+
Object.defineProperty(global, p, {
|
|
317
|
+
get: () => overrideObject.get(p),
|
|
318
|
+
set: (value2) => overrideObject.set(p, value2),
|
|
319
|
+
configurable: true
|
|
320
|
+
});
|
|
321
|
+
overrideObject.set(p, value);
|
|
322
|
+
Reflect.set(target, p, value, receiver);
|
|
323
|
+
} catch {
|
|
324
|
+
}
|
|
325
|
+
return true;
|
|
326
|
+
},
|
|
327
|
+
deleteProperty(target, p) {
|
|
328
|
+
Reflect.deleteProperty(global, p);
|
|
329
|
+
overrideObject.delete(p);
|
|
330
|
+
return Reflect.deleteProperty(target, p);
|
|
331
|
+
},
|
|
332
|
+
defineProperty(target, p, attributes) {
|
|
333
|
+
if (attributes.writable && "value" in attributes) ; else if (attributes.get) {
|
|
334
|
+
overrideObject.delete(p);
|
|
335
|
+
Reflect.defineProperty(global, p, attributes);
|
|
336
|
+
}
|
|
337
|
+
return Reflect.defineProperty(target, p, attributes);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
302
340
|
globalKeys.forEach((key) => {
|
|
303
341
|
if (!win[key])
|
|
304
342
|
return;
|
|
305
|
-
const proxy = new Proxy(win[key], {
|
|
306
|
-
get(target, p, receiver) {
|
|
307
|
-
if (overrideObject.has(p))
|
|
308
|
-
return overrideObject.get(p);
|
|
309
|
-
return Reflect.get(target, p, receiver);
|
|
310
|
-
},
|
|
311
|
-
set(target, p, value, receiver) {
|
|
312
|
-
try {
|
|
313
|
-
Object.defineProperty(global, p, {
|
|
314
|
-
get: () => overrideObject.get(p),
|
|
315
|
-
set: (value2) => overrideObject.set(p, value2),
|
|
316
|
-
configurable: true
|
|
317
|
-
});
|
|
318
|
-
overrideObject.set(p, value);
|
|
319
|
-
Reflect.set(target, p, value, receiver);
|
|
320
|
-
} catch {
|
|
321
|
-
}
|
|
322
|
-
return true;
|
|
323
|
-
},
|
|
324
|
-
deleteProperty(target, p) {
|
|
325
|
-
Reflect.deleteProperty(global, p);
|
|
326
|
-
overrideObject.delete(p);
|
|
327
|
-
return Reflect.deleteProperty(target, p);
|
|
328
|
-
},
|
|
329
|
-
defineProperty(target, p, attributes) {
|
|
330
|
-
if (attributes.writable && "value" in attributes) ; else if (attributes.get) {
|
|
331
|
-
overrideObject.delete(p);
|
|
332
|
-
Reflect.defineProperty(global, p, attributes);
|
|
333
|
-
}
|
|
334
|
-
return Reflect.defineProperty(target, p, attributes);
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
343
|
Object.defineProperty(global, key, {
|
|
338
344
|
get() {
|
|
339
|
-
return
|
|
345
|
+
return globalProxy;
|
|
340
346
|
},
|
|
341
347
|
configurable: true
|
|
342
348
|
});
|
|
343
349
|
});
|
|
344
|
-
|
|
350
|
+
const globalThisProxy = new Proxy(global.globalThis, {
|
|
345
351
|
set(target, key, value, receiver) {
|
|
346
352
|
overrideObject.set(key, value);
|
|
347
353
|
return Reflect.set(target, key, value, receiver);
|
|
@@ -360,6 +366,9 @@ function populateGlobal(global, win) {
|
|
|
360
366
|
return Reflect.defineProperty(target, p, attributes);
|
|
361
367
|
}
|
|
362
368
|
});
|
|
369
|
+
global.globalThis = globalThisProxy;
|
|
370
|
+
if (global.global)
|
|
371
|
+
global.global = globalThisProxy;
|
|
363
372
|
skipKeys.forEach((k) => keys.add(k));
|
|
364
373
|
return {
|
|
365
374
|
keys,
|
|
@@ -455,7 +464,7 @@ var happy = {
|
|
|
455
464
|
async setup(global) {
|
|
456
465
|
const { Window, GlobalWindow } = await importModule("happy-dom");
|
|
457
466
|
const win = new (GlobalWindow || Window)();
|
|
458
|
-
const { keys, allowRewrite } = populateGlobal(global, win);
|
|
467
|
+
const { keys, allowRewrite } = populateGlobal(global, win, { bindFunctions: true });
|
|
459
468
|
const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
|
|
460
469
|
return {
|
|
461
470
|
teardown(global2) {
|
|
@@ -486,7 +495,7 @@ async function setupGlobalEnv(config) {
|
|
|
486
495
|
globalSetup = true;
|
|
487
496
|
setupConsoleLogSpy();
|
|
488
497
|
if (config.globals)
|
|
489
|
-
(await import('./chunk-integrations-globals.
|
|
498
|
+
(await import('./chunk-integrations-globals.60fc66ef.js')).registerApiGlobally();
|
|
490
499
|
}
|
|
491
500
|
function setupDefines(defines) {
|
|
492
501
|
for (const key in defines)
|
|
@@ -513,33 +522,39 @@ function setupConsoleLogSpy() {
|
|
|
513
522
|
}
|
|
514
523
|
function sendStdout(taskId) {
|
|
515
524
|
const buffer = stdoutBuffer.get(taskId);
|
|
516
|
-
if (buffer)
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
timer.stdoutTime
|
|
527
|
-
|
|
525
|
+
if (!buffer)
|
|
526
|
+
return;
|
|
527
|
+
const content = buffer.map((i) => String(i)).join("");
|
|
528
|
+
if (!content.trim())
|
|
529
|
+
return;
|
|
530
|
+
const timer = timers.get(taskId);
|
|
531
|
+
rpc().onUserConsoleLog({
|
|
532
|
+
type: "stdout",
|
|
533
|
+
content,
|
|
534
|
+
taskId,
|
|
535
|
+
time: timer.stdoutTime || RealDate.now(),
|
|
536
|
+
size: buffer.length
|
|
537
|
+
});
|
|
538
|
+
stdoutBuffer.set(taskId, []);
|
|
539
|
+
timer.stdoutTime = 0;
|
|
528
540
|
}
|
|
529
541
|
function sendStderr(taskId) {
|
|
530
542
|
const buffer = stderrBuffer.get(taskId);
|
|
531
|
-
if (buffer)
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
timer.stderrTime
|
|
542
|
-
|
|
543
|
+
if (!buffer)
|
|
544
|
+
return;
|
|
545
|
+
const content = buffer.map((i) => String(i)).join("");
|
|
546
|
+
if (!content.trim())
|
|
547
|
+
return;
|
|
548
|
+
const timer = timers.get(taskId);
|
|
549
|
+
rpc().onUserConsoleLog({
|
|
550
|
+
type: "stderr",
|
|
551
|
+
content,
|
|
552
|
+
taskId,
|
|
553
|
+
time: timer.stderrTime || RealDate.now(),
|
|
554
|
+
size: buffer.length
|
|
555
|
+
});
|
|
556
|
+
stderrBuffer.set(taskId, []);
|
|
557
|
+
timer.stderrTime = 0;
|
|
543
558
|
}
|
|
544
559
|
const stdout = new Writable({
|
|
545
560
|
write(data, encoding, callback) {
|
|
@@ -643,6 +658,9 @@ function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
|
643
658
|
return clone2;
|
|
644
659
|
}
|
|
645
660
|
}
|
|
661
|
+
function normalizeErrorMessage(message) {
|
|
662
|
+
return message.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
663
|
+
}
|
|
646
664
|
function processError(err) {
|
|
647
665
|
if (!err)
|
|
648
666
|
return err;
|
|
@@ -659,6 +677,10 @@ function processError(err) {
|
|
|
659
677
|
err.expected = stringify(err.expected);
|
|
660
678
|
if (typeof err.actual !== "string")
|
|
661
679
|
err.actual = stringify(err.actual);
|
|
680
|
+
if (typeof err.message === "string")
|
|
681
|
+
err.message = normalizeErrorMessage(err.message);
|
|
682
|
+
if (typeof err.cause === "object" && err.cause.message === "string")
|
|
683
|
+
err.cause.message = normalizeErrorMessage(err.cause.message);
|
|
662
684
|
try {
|
|
663
685
|
return serializeError(err);
|
|
664
686
|
} catch (e) {
|
|
@@ -739,7 +761,6 @@ async function collectTests(paths, config) {
|
|
|
739
761
|
state: "fail",
|
|
740
762
|
error: processError(e)
|
|
741
763
|
};
|
|
742
|
-
stdout().write("\0");
|
|
743
764
|
}
|
|
744
765
|
calculateHash(file);
|
|
745
766
|
const hasOnlyTasks = someTasksAreOnly(file);
|
|
@@ -1037,21 +1058,39 @@ function clearModuleMocks() {
|
|
|
1037
1058
|
}
|
|
1038
1059
|
|
|
1039
1060
|
async function run(files, config) {
|
|
1040
|
-
var _a;
|
|
1041
1061
|
await setupGlobalEnv(config);
|
|
1042
1062
|
const workerState = getWorkerState();
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1063
|
+
const envs = ["node", "jsdom", "happy-dom"];
|
|
1064
|
+
const filesWithEnv = await Promise.all(files.map(async (file) => {
|
|
1065
|
+
var _a;
|
|
1046
1066
|
const code = await promises.readFile(file, "utf-8");
|
|
1047
1067
|
const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
|
|
1048
|
-
if (!
|
|
1049
|
-
throw new Error(`Unsupported environment: ${env}`);
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1068
|
+
if (!envs.includes(env))
|
|
1069
|
+
throw new Error(`Unsupported environment: "${env}" in ${file}`);
|
|
1070
|
+
return {
|
|
1071
|
+
file,
|
|
1072
|
+
env
|
|
1073
|
+
};
|
|
1074
|
+
}));
|
|
1075
|
+
const filesByEnv = filesWithEnv.reduce((acc, { file, env }) => {
|
|
1076
|
+
acc[env] || (acc[env] = []);
|
|
1077
|
+
acc[env].push(file);
|
|
1078
|
+
return acc;
|
|
1079
|
+
}, {});
|
|
1080
|
+
for (const env of envs) {
|
|
1081
|
+
const environment = env;
|
|
1082
|
+
const files2 = filesByEnv[environment];
|
|
1083
|
+
if (!files2 || !files2.length)
|
|
1084
|
+
continue;
|
|
1085
|
+
await withEnv(environment, config.environmentOptions || {}, async () => {
|
|
1086
|
+
for (const file of files2) {
|
|
1087
|
+
workerState.mockMap.clear();
|
|
1088
|
+
resetModules();
|
|
1089
|
+
workerState.filepath = file;
|
|
1090
|
+
await startTests([file], config);
|
|
1091
|
+
workerState.filepath = void 0;
|
|
1092
|
+
}
|
|
1053
1093
|
});
|
|
1054
|
-
workerState.filepath = void 0;
|
|
1055
1094
|
}
|
|
1056
1095
|
}
|
|
1057
1096
|
|
package/dist/worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { h as resolve, a as getWorkerState
|
|
2
|
-
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.
|
|
1
|
+
import { h as resolve, a as getWorkerState } from './chunk-utils-global.a5a8641f.js';
|
|
2
|
+
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.1536f168.js';
|
|
3
3
|
import { d as distDir } from './chunk-constants.0567483c.js';
|
|
4
|
-
import { e as executeInViteNode } from './chunk-runtime-mocker.
|
|
4
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.acd615bd.js';
|
|
5
5
|
import { r as rpc } from './chunk-runtime-rpc.63398738.js';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
@@ -54,7 +54,6 @@ async function startViteNode(ctx) {
|
|
|
54
54
|
function init(ctx) {
|
|
55
55
|
if (typeof __vitest_worker__ !== "undefined" && ctx.config.threads && ctx.config.isolate)
|
|
56
56
|
throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
|
|
57
|
-
stdout().write("\0");
|
|
58
57
|
const { config, port, id } = ctx;
|
|
59
58
|
process.env.VITEST_WORKER_ID = String(id);
|
|
60
59
|
globalThis.__vitest_worker__ = {
|