vitest 4.0.0-beta.9 → 4.0.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 (83) hide show
  1. package/LICENSE.md +86 -102
  2. package/browser/context.d.ts +7 -0
  3. package/browser/context.js +20 -0
  4. package/dist/browser.d.ts +24 -7
  5. package/dist/browser.js +15 -5
  6. package/dist/chunks/{base.CA5N8Af0.js → base.CtHM3ryk.js} +36 -36
  7. package/dist/chunks/{benchmark.CJUa-Hsa.js → benchmark.DHKMYAts.js} +2 -2
  8. package/dist/chunks/{browser.d.DtfyY9yS.d.ts → browser.d.B9iJzZyn.d.ts} +3 -3
  9. package/dist/chunks/{cac.Dt7e1TIu.js → cac.B99MQg-w.js} +47 -73
  10. package/dist/chunks/{cli-api.eAzsLIxz.js → cli-api.PwHwIMss.js} +1519 -294
  11. package/dist/chunks/{config.d.DacWrqWe.d.ts → config.d.u2CUDWwS.d.ts} +5 -19
  12. package/dist/chunks/{console.7h5kHUIf.js → console.CTJL2nuH.js} +4 -6
  13. package/dist/chunks/{coverage.CDRAMTt7.js → coverage.FU3w4IrQ.js} +125 -1108
  14. package/dist/chunks/{creator.KEg6n5IC.js → creator.DucAaYBz.js} +10 -37
  15. package/dist/chunks/{defaults.CXFFjsi8.js → defaults.BOqNVLsY.js} +0 -1
  16. package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
  17. package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
  18. package/dist/chunks/{global.d.K6uBQHzY.d.ts → global.d.BgJSTpgQ.d.ts} +2 -17
  19. package/dist/chunks/{globals.CJrTTbxC.js → globals.BGT_RUsD.js} +11 -7
  20. package/dist/chunks/{index.BjKEiSn0.js → index.BdSLhLDZ.js} +3 -3
  21. package/dist/chunks/{index.DfviD7lX.js → index.CbWINfS7.js} +49 -21
  22. package/dist/chunks/{index.BIP7prJq.js → index.CcRZ6fUh.js} +1493 -114
  23. package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
  24. package/dist/chunks/{index.C832ioot.js → index.RwjEGCQ0.js} +4 -4
  25. package/dist/chunks/init-forks.DSafeltJ.js +54 -0
  26. package/dist/chunks/init-threads.SUtZ-067.js +17 -0
  27. package/dist/chunks/init.B2EESLQM.js +213 -0
  28. package/dist/chunks/{inspector.CvQD-Nie.js → inspector.DLZxSeU3.js} +2 -6
  29. package/dist/chunks/{moduleRunner.d.DxTLreRD.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +9 -14
  30. package/dist/chunks/{node.CyipiPvJ.js → node.BwAWWjHZ.js} +3 -4
  31. package/dist/chunks/{plugin.d.CIk0YiKb.d.ts → plugin.d.DQU1R5px.d.ts} +1 -1
  32. package/dist/chunks/{reporters.d.DmP-iHLr.d.ts → reporters.d.BMKt7f6I.d.ts} +1064 -1021
  33. package/dist/chunks/{resolveSnapshotEnvironment.Bvv2zr69.js → resolveSnapshotEnvironment.DJJKMKxb.js} +7 -8
  34. package/dist/chunks/{rpc.BKr6mtxz.js → rpc.cD77ENhU.js} +13 -14
  35. package/dist/chunks/{setup-common.B7I37Tji.js → setup-common.DR1sucx6.js} +6 -6
  36. package/dist/chunks/{startModuleRunner.BDRvKSdz.js → startModuleRunner.C2tTvmF9.js} +126 -110
  37. package/dist/chunks/{test.BAlBebnP.js → test.C3RPt8JR.js} +7 -7
  38. package/dist/chunks/{utils.D2R2NiOH.js → utils.CG9h5ccR.js} +2 -5
  39. package/dist/chunks/{vi.BB37KeLx.js → vi.BZvkKVkM.js} +61 -164
  40. package/dist/chunks/{vm.CjLTDaST.js → vm.DBeOXrP9.js} +20 -29
  41. package/dist/chunks/{worker.d.B2r4Ln6p.d.ts → worker.d.BFk-vvBU.d.ts} +42 -6
  42. package/dist/cli.js +12 -11
  43. package/dist/config.cjs +0 -1
  44. package/dist/config.d.ts +11 -13
  45. package/dist/config.js +1 -1
  46. package/dist/coverage.d.ts +7 -6
  47. package/dist/coverage.js +3 -14
  48. package/dist/environments.d.ts +3 -6
  49. package/dist/environments.js +1 -1
  50. package/dist/index.d.ts +20 -25
  51. package/dist/index.js +11 -7
  52. package/dist/module-evaluator.d.ts +5 -4
  53. package/dist/module-evaluator.js +11 -13
  54. package/dist/module-runner.js +5 -5
  55. package/dist/node.d.ts +82 -25
  56. package/dist/node.js +23 -20
  57. package/dist/reporters.d.ts +10 -9
  58. package/dist/reporters.js +12 -11
  59. package/dist/runners.d.ts +1 -1
  60. package/dist/runners.js +9 -7
  61. package/dist/snapshot.js +3 -3
  62. package/dist/suite.js +4 -3
  63. package/dist/worker.d.ts +26 -0
  64. package/dist/worker.js +45 -165
  65. package/dist/workers/forks.js +26 -43
  66. package/dist/workers/runVmTests.js +16 -12
  67. package/dist/workers/threads.js +26 -31
  68. package/dist/workers/vmForks.js +26 -39
  69. package/dist/workers/vmThreads.js +26 -29
  70. package/package.json +48 -32
  71. package/worker.d.ts +1 -0
  72. package/browser.d.ts +0 -1
  73. package/dist/chunks/environment.d.2fYMoz3o.d.ts +0 -66
  74. package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
  75. package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
  76. package/dist/chunks/typechecker.DB-fIMaH.js +0 -805
  77. package/dist/chunks/utils.C2YI6McM.js +0 -52
  78. package/dist/chunks/worker.d.DJ6qxO2w.d.ts +0 -8
  79. package/dist/workers.d.ts +0 -38
  80. package/dist/workers.js +0 -49
  81. package/execute.d.ts +0 -1
  82. package/utils.d.ts +0 -1
  83. package/workers.d.ts +0 -1
package/LICENSE.md CHANGED
@@ -57,6 +57,87 @@ Repository: git+https://github.com/antfu/install-pkg.git
57
57
 
58
58
  ---------------------------------------
59
59
 
60
+ ## @jridgewell/resolve-uri
61
+ License: MIT
62
+ By: Justin Ridgewell
63
+ Repository: https://github.com/jridgewell/resolve-uri
64
+
65
+ > Copyright 2019 Justin Ridgewell <jridgewell@google.com>
66
+ >
67
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
68
+ > of this software and associated documentation files (the "Software"), to deal
69
+ > in the Software without restriction, including without limitation the rights
70
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
71
+ > copies of the Software, and to permit persons to whom the Software is
72
+ > furnished to do so, subject to the following conditions:
73
+ >
74
+ > The above copyright notice and this permission notice shall be included in
75
+ > all copies or substantial portions of the Software.
76
+ >
77
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
78
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
79
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
80
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
81
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
82
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
83
+ > SOFTWARE.
84
+
85
+ ---------------------------------------
86
+
87
+ ## @jridgewell/sourcemap-codec
88
+ License: MIT
89
+ By: Justin Ridgewell
90
+ Repository: git+https://github.com/jridgewell/sourcemaps.git
91
+
92
+ > Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
93
+ >
94
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
95
+ > of this software and associated documentation files (the "Software"), to deal
96
+ > in the Software without restriction, including without limitation the rights
97
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
98
+ > copies of the Software, and to permit persons to whom the Software is
99
+ > furnished to do so, subject to the following conditions:
100
+ >
101
+ > The above copyright notice and this permission notice shall be included in
102
+ > all copies or substantial portions of the Software.
103
+ >
104
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ > SOFTWARE.
111
+
112
+ ---------------------------------------
113
+
114
+ ## @jridgewell/trace-mapping
115
+ License: MIT
116
+ By: Justin Ridgewell
117
+ Repository: git+https://github.com/jridgewell/sourcemaps.git
118
+
119
+ > Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
120
+ >
121
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
122
+ > of this software and associated documentation files (the "Software"), to deal
123
+ > in the Software without restriction, including without limitation the rights
124
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
125
+ > copies of the Software, and to permit persons to whom the Software is
126
+ > furnished to do so, subject to the following conditions:
127
+ >
128
+ > The above copyright notice and this permission notice shall be included in
129
+ > all copies or substantial portions of the Software.
130
+ >
131
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
134
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
135
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
136
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
137
+ > SOFTWARE.
138
+
139
+ ---------------------------------------
140
+
60
141
  ## @sinonjs/commons
61
142
  License: BSD-3-Clause
62
143
  Repository: git+https://github.com/sinonjs/commons.git
@@ -199,43 +280,14 @@ Repository: egoist/cac
199
280
 
200
281
  ---------------------------------------
201
282
 
202
- ## chai-subset
203
- License: MIT
204
- By: Andrii Shumada, Robert Herhold
205
- Repository: https://github.com/debitoor/chai-subset.git
206
-
207
- > The MIT License (MIT)
208
- >
209
- > Copyright (c) 2014
210
- >
211
- > Permission is hereby granted, free of charge, to any person obtaining a copy
212
- > of this software and associated documentation files (the "Software"), to deal
213
- > in the Software without restriction, including without limitation the rights
214
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
215
- > copies of the Software, and to permit persons to whom the Software is
216
- > furnished to do so, subject to the following conditions:
217
- >
218
- > The above copyright notice and this permission notice shall be included in all
219
- > copies or substantial portions of the Software.
220
- >
221
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
222
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
223
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
224
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
225
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
226
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
227
- > SOFTWARE.
228
-
229
- ---------------------------------------
230
-
231
- ## find-up
283
+ ## empathic
232
284
  License: MIT
233
- By: Sindre Sorhus
234
- Repository: sindresorhus/find-up
285
+ By: Luke Edwards
286
+ Repository: lukeed/empathic
235
287
 
236
288
  > MIT License
237
289
  >
238
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
290
+ > Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
239
291
  >
240
292
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
241
293
  >
@@ -329,7 +381,7 @@ Repository: lukeed/kleur
329
381
  ## local-pkg
330
382
  License: MIT
331
383
  By: Anthony Fu
332
- Repository: git+https://github.com/antfu/local-pkg.git
384
+ Repository: git+https://github.com/antfu-collective/local-pkg.git
333
385
 
334
386
  > MIT License
335
387
  >
@@ -355,23 +407,6 @@ Repository: git+https://github.com/antfu/local-pkg.git
355
407
 
356
408
  ---------------------------------------
357
409
 
358
- ## locate-path
359
- License: MIT
360
- By: Sindre Sorhus
361
- Repository: sindresorhus/locate-path
362
-
363
- > MIT License
364
- >
365
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
366
- >
367
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
368
- >
369
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
370
- >
371
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
372
-
373
- ---------------------------------------
374
-
375
410
  ## mime
376
411
  License: MIT
377
412
  By: Robert Kieffer
@@ -429,40 +464,6 @@ Repository: unjs/mlly
429
464
 
430
465
  ---------------------------------------
431
466
 
432
- ## p-limit
433
- License: MIT
434
- By: Sindre Sorhus
435
- Repository: sindresorhus/p-limit
436
-
437
- > MIT License
438
- >
439
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
440
- >
441
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
442
- >
443
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
444
- >
445
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
446
-
447
- ---------------------------------------
448
-
449
- ## p-locate
450
- License: MIT
451
- By: Sindre Sorhus
452
- Repository: sindresorhus/p-locate
453
-
454
- > MIT License
455
- >
456
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
457
- >
458
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
459
- >
460
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
461
- >
462
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
463
-
464
- ---------------------------------------
465
-
466
467
  ## package-manager-detector
467
468
  License: MIT
468
469
  By: Anthony Fu
@@ -688,20 +689,3 @@ Repository: git+https://github.com/websockets/ws.git
688
689
  > COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
689
690
  > IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
690
691
  > CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
691
-
692
- ---------------------------------------
693
-
694
- ## yocto-queue
695
- License: MIT
696
- By: Sindre Sorhus
697
- Repository: sindresorhus/yocto-queue
698
-
699
- > MIT License
700
- >
701
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
702
- >
703
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
704
- >
705
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
706
- >
707
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ // @ts-ignore -- @vitest/browser-playwright might not be installed
2
+ export * from '@vitest/browser-playwright/context'
3
+ // @ts-ignore -- @vitest/browser-webdriverio might not be installed
4
+ export * from '@vitest/browser-webdriverio/context'
5
+ // @ts-ignore -- @vitest/browser-preview might not be installed
6
+ export * from '@vitest/browser-preview/context'
7
+ export { BrowserCommands, FsOptions } from 'vitest/internal/browser'
@@ -0,0 +1,20 @@
1
+ // Vitest resolves "vitest/browser" as a virtual module instead
2
+
3
+ // fake exports for static analysis
4
+ export const page = null
5
+ export const server = null
6
+ export const userEvent = null
7
+ export const cdp = null
8
+ export const commands = null
9
+ export const locators = null
10
+ export const utils = null
11
+
12
+ const pool = globalThis.__vitest_worker__?.ctx?.pool
13
+
14
+ throw new Error(
15
+ // eslint-disable-next-line prefer-template
16
+ 'vitest/browser can be imported only inside the Browser Mode. '
17
+ + (pool
18
+ ? `Your test is running in ${pool} pool. Make sure your regular tests are excluded from the "test.include" glob pattern.`
19
+ : 'Instead, it was imported outside of Vitest.'),
20
+ )
package/dist/browser.d.ts CHANGED
@@ -1,18 +1,22 @@
1
- import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.DacWrqWe.js';
1
+ import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.u2CUDWwS.js';
2
2
  import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
- import { V as VitestModuleRunner } from './chunks/moduleRunner.d.DxTLreRD.js';
5
- export { collectTests, processError, startTests } from '@vitest/runner';
4
+ import { V as VitestModuleRunner } from './chunks/moduleRunner.d.YtNsMIoJ.js';
5
+ export { collectTests, startTests } from '@vitest/runner';
6
6
  import * as _vitest_spy from '@vitest/spy';
7
7
  export { _vitest_spy as SpyModule };
8
- export { LoupeOptions, ParsedStack, StringifyOptions, format, getSafeTimers, inspect, stringify } from '@vitest/utils';
9
- export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
8
+ export { LoupeOptions, ParsedStack, StringifyOptions } from '@vitest/utils';
9
+ export { format, inspect, stringify } from '@vitest/utils/display';
10
+ export { processError } from '@vitest/utils/error';
11
+ export { getType } from '@vitest/utils/helpers';
12
+ export { DecodedMap, getOriginalPosition } from '@vitest/utils/source-map';
13
+ export { getSafeTimers, setSafeTimers } from '@vitest/utils/timers';
10
14
  import '@vitest/pretty-format';
11
15
  import '@vitest/snapshot';
12
16
  import 'node:vm';
13
17
  import 'vite/module-runner';
14
- import './chunks/worker.d.B2r4Ln6p.js';
15
- import './chunks/environment.d.2fYMoz3o.js';
18
+ import './chunks/worker.d.BFk-vvBU.js';
19
+ import './chunks/environment.d.CrsxCzP1.js';
16
20
  import '@vitest/mocker';
17
21
  import './chunks/mocker.d.BE_2ls6u.js';
18
22
 
@@ -28,4 +32,17 @@ declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
28
32
  declare function loadDiffConfig(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<SerializedDiffOptions | undefined>;
29
33
  declare function loadSnapshotSerializers(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<void>;
30
34
 
35
+ interface FsOptions {
36
+ encoding?: BufferEncoding;
37
+ flag?: string | number;
38
+ }
39
+ interface BrowserCommands {
40
+ readFile: (path: string, options?: BufferEncoding | FsOptions) => Promise<string>;
41
+ writeFile: (path: string, content: string, options?: BufferEncoding | (FsOptions & {
42
+ mode?: number | string;
43
+ })) => Promise<void>;
44
+ removeFile: (path: string) => Promise<void>;
45
+ }
46
+
31
47
  export { loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
48
+ export type { BrowserCommands, FsOptions };
package/dist/browser.js CHANGED
@@ -1,9 +1,19 @@
1
- export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.B7I37Tji.js';
2
- export { collectTests, processError, startTests } from '@vitest/runner';
1
+ export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.DR1sucx6.js';
2
+ export { collectTests, startTests } from '@vitest/runner';
3
3
  import * as spyModule from '@vitest/spy';
4
4
  export { spyModule as SpyModule };
5
- export { format, getSafeTimers, inspect, stringify } from '@vitest/utils';
6
- export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
5
+ export { format, inspect, stringify } from '@vitest/utils/display';
6
+ export { processError } from '@vitest/utils/error';
7
+ export { getType } from '@vitest/utils/helpers';
8
+ export { DecodedMap, getOriginalPosition } from '@vitest/utils/source-map';
9
+ export { getSafeTimers, setSafeTimers } from '@vitest/utils/timers';
7
10
  import './chunks/coverage.D_JHT54q.js';
8
11
  import '@vitest/snapshot';
9
- import './chunks/utils.D2R2NiOH.js';
12
+ import './chunks/utils.CG9h5ccR.js';
13
+
14
+ /**
15
+ * @internal
16
+ */
17
+ const __INTERNAL = { _extendedMethods: /* @__PURE__ */ new Set() };
18
+
19
+ export { __INTERNAL };
@@ -1,20 +1,21 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import * as spyModule from '@vitest/spy';
3
- import { EvaluatedModules } from 'vite/module-runner';
4
- import { s as startVitestModuleRunner } from './startModuleRunner.BDRvKSdz.js';
3
+ import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
4
+ import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startModuleRunner.C2tTvmF9.js';
5
5
  import { performance } from 'node:perf_hooks';
6
6
  import { startTests, collectTests } from '@vitest/runner';
7
- import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './resolveSnapshotEnvironment.Bvv2zr69.js';
8
- import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.B7I37Tji.js';
9
- import { g as globalExpect, v as vi } from './vi.BB37KeLx.js';
10
- import { c as closeInspector } from './inspector.CvQD-Nie.js';
7
+ import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './resolveSnapshotEnvironment.DJJKMKxb.js';
8
+ import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.DR1sucx6.js';
9
+ import { g as globalExpect, v as vi } from './vi.BZvkKVkM.js';
10
+ import { c as closeInspector } from './inspector.DLZxSeU3.js';
11
11
  import { createRequire } from 'node:module';
12
12
  import timers from 'node:timers';
13
13
  import timersPromises from 'node:timers/promises';
14
14
  import util from 'node:util';
15
- import { KNOWN_ASSET_TYPES, getSafeTimers } from '@vitest/utils';
16
- import { i as index } from './index.C832ioot.js';
17
- import { g as getWorkerState, r as resetModules, p as provideWorkerState } from './utils.D2R2NiOH.js';
15
+ import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
16
+ import { getSafeTimers } from '@vitest/utils/timers';
17
+ import { i as index } from './index.RwjEGCQ0.js';
18
+ import { g as getWorkerState, r as resetModules, p as provideWorkerState } from './utils.CG9h5ccR.js';
18
19
 
19
20
  // this should only be used in Node
20
21
  let globalSetup = false;
@@ -25,20 +26,19 @@ async function setupGlobalEnv(config, { environment }, moduleRunner) {
25
26
  });
26
27
  const state = getWorkerState();
27
28
  if (!state.config.snapshotOptions.snapshotEnvironment) state.config.snapshotOptions.snapshotEnvironment = await resolveSnapshotEnvironment(config, moduleRunner);
28
- if (globalSetup) return;
29
- globalSetup = true;
30
- const viteEnvironment = environment.viteEnvironment || environment.name;
31
- if (viteEnvironment === "client") {
32
- const _require = createRequire(import.meta.url);
33
- _require.extensions[".css"] = resolveCss, _require.extensions[".scss"] = resolveCss, _require.extensions[".sass"] = resolveCss, _require.extensions[".less"] = resolveCss, KNOWN_ASSET_TYPES.forEach((type) => {
34
- _require.extensions[`.${type}`] = resolveAsset;
35
- }), process.env.SSR = "";
36
- } else process.env.SSR = "1";
37
- if (globalThis.__vitest_required__ = {
38
- util,
39
- timers,
40
- timersPromises
41
- }, !config.disableConsoleIntercept) await setupConsoleLogSpy();
29
+ if (!globalSetup) {
30
+ if (globalSetup = true, (environment.viteEnvironment || environment.name) === "client") {
31
+ const _require = createRequire(import.meta.url);
32
+ _require.extensions[".css"] = resolveCss, _require.extensions[".scss"] = resolveCss, _require.extensions[".sass"] = resolveCss, _require.extensions[".less"] = resolveCss, KNOWN_ASSET_TYPES.forEach((type) => {
33
+ _require.extensions[`.${type}`] = resolveAsset;
34
+ }), process.env.SSR = "";
35
+ } else process.env.SSR = "1";
36
+ if (globalThis.__vitest_required__ = {
37
+ util,
38
+ timers,
39
+ timersPromises
40
+ }, !config.disableConsoleIntercept) await setupConsoleLogSpy();
41
+ }
42
42
  }
43
43
  function resolveCss(mod) {
44
44
  mod.exports = "";
@@ -47,7 +47,7 @@ function resolveAsset(mod, url) {
47
47
  mod.exports = url;
48
48
  }
49
49
  async function setupConsoleLogSpy() {
50
- const { createCustomConsole } = await import('./console.7h5kHUIf.js');
50
+ const { createCustomConsole } = await import('./console.CTJL2nuH.js');
51
51
  globalThis.console = createCustomConsole();
52
52
  }
53
53
  async function withEnv({ environment }, options, fn) {
@@ -64,53 +64,53 @@ async function withEnv({ environment }, options, fn) {
64
64
 
65
65
  // browser shouldn't call this!
66
66
  async function run(method, files, config, environment, moduleRunner) {
67
- const workerState = getWorkerState(), isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true), isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true), isolate = isIsolatedThreads || isIsolatedForks;
68
- if (await setupGlobalEnv(config, environment, moduleRunner), await startCoverageInsideWorker(config.coverage, moduleRunner, { isolate }), config.chaiConfig) setupChaiConfig(config.chaiConfig);
67
+ const workerState = getWorkerState();
68
+ if (await setupGlobalEnv(config, environment, moduleRunner), await startCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.isolate }), config.chaiConfig) setupChaiConfig(config.chaiConfig);
69
69
  const runner = await resolveTestRunner(config, moduleRunner);
70
70
  workerState.onCancel.then((reason) => {
71
71
  closeInspector(config), runner.cancel?.(reason);
72
72
  }), workerState.durations.prepare = performance.now() - workerState.durations.prepare, workerState.durations.environment = performance.now(), await withEnv(environment, environment.options || config.environmentOptions || {}, async () => {
73
73
  workerState.durations.environment = performance.now() - workerState.durations.environment;
74
74
  for (const file of files) {
75
- if (isolate) moduleRunner.mocker.reset(), resetModules(workerState.evaluatedModules, true);
75
+ if (config.isolate) moduleRunner.mocker.reset(), resetModules(workerState.evaluatedModules, true);
76
76
  if (workerState.filepath = file.filepath, method === "run") await startTests([file], runner);
77
77
  else await collectTests([file], runner);
78
78
  // mocks should not affect different files
79
79
  vi.resetConfig(), vi.restoreAllMocks();
80
80
  }
81
- await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate });
81
+ await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.isolate });
82
82
  }), workerState.environmentTeardownRun = true;
83
83
  }
84
84
 
85
85
  let _moduleRunner;
86
- const evaluatedModules = new EvaluatedModules(), moduleExecutionInfo = /* @__PURE__ */ new Map();
86
+ const evaluatedModules = new VitestEvaluatedModules(), moduleExecutionInfo = /* @__PURE__ */ new Map();
87
87
  function startModuleRunner(options) {
88
88
  return _moduleRunner || (_moduleRunner = startVitestModuleRunner(options), _moduleRunner);
89
89
  }
90
+ /** @experimental */
90
91
  async function runBaseTests(method, state) {
91
92
  const { ctx } = state;
92
93
  if (state.evaluatedModules = evaluatedModules, state.moduleExecutionInfo = moduleExecutionInfo, provideWorkerState(globalThis, state), ctx.invalidates) ctx.invalidates.forEach((filepath) => {
93
- const modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
94
- modules.forEach((module) => {
94
+ (state.evaluatedModules.fileToModulesMap.get(filepath) || []).forEach((module) => {
95
95
  state.evaluatedModules.invalidateModule(module);
96
96
  });
97
- // evaluatedModules.delete(fsPath)
98
- // evaluatedModules.delete(`mock:${fsPath}`)
99
97
  });
100
98
  ctx.files.forEach((i) => {
101
- const filepath = typeof i === "string" ? i : i.filepath, modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
102
- modules.forEach((module) => {
99
+ const filepath = typeof i === "string" ? i : i.filepath;
100
+ (state.evaluatedModules.fileToModulesMap.get(filepath) || []).forEach((module) => {
103
101
  state.evaluatedModules.invalidateModule(module);
104
102
  });
105
103
  });
106
104
  const executor = startModuleRunner({
107
105
  state,
108
106
  evaluatedModules: state.evaluatedModules,
109
- spyModule
107
+ spyModule,
108
+ createImportMeta: createNodeImportMeta
110
109
  }), fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
111
110
  filepath: f,
112
111
  testLocations: void 0
113
112
  } : f);
113
+ // we could load @vite/env, but it would take ~8ms, while this takes ~0,02ms
114
114
  if (ctx.config.serializedDefines) try {
115
115
  runInThisContext(`(() =>{\n${ctx.config.serializedDefines}})()`, {
116
116
  lineOffset: 1,
@@ -1,7 +1,7 @@
1
1
  import { getCurrentSuite } from '@vitest/runner';
2
2
  import { createChainable } from '@vitest/runner/utils';
3
- import { noop } from '@vitest/utils';
4
- import { g as getWorkerState } from './utils.D2R2NiOH.js';
3
+ import { noop } from '@vitest/utils/helpers';
4
+ import { g as getWorkerState } from './utils.CG9h5ccR.js';
5
5
 
6
6
  const benchFns = /* @__PURE__ */ new WeakMap(), benchOptsMap = /* @__PURE__ */ new WeakMap();
7
7
  function getBenchOptions(key) {
@@ -1,4 +1,5 @@
1
- import { T as TestExecutionMethod } from './worker.d.B2r4Ln6p.js';
1
+ import { FileSpecification } from '@vitest/runner';
2
+ import { T as TestExecutionMethod } from './worker.d.BFk-vvBU.js';
2
3
 
3
4
  type SerializedTestSpecification = [project: {
4
5
  name: string | undefined;
@@ -10,9 +11,8 @@ type SerializedTestSpecification = [project: {
10
11
 
11
12
  interface BrowserTesterOptions {
12
13
  method: TestExecutionMethod;
13
- files: string[];
14
+ files: FileSpecification[];
14
15
  providedContext: string;
15
- startTime: number;
16
16
  }
17
17
 
18
18
  export type { BrowserTesterOptions as B, SerializedTestSpecification as S };