vitest 4.1.0-beta.3 → 4.1.0-beta.4

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 (43) hide show
  1. package/LICENSE.md +116 -1
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +1 -1
  4. package/dist/chunks/{base.BawQY8vy.js → base.C_KzYoIG.js} +10 -6
  5. package/dist/chunks/{browser.d.CweQ2M9y.d.ts → browser.d.B8ZWo0aT.d.ts} +1 -1
  6. package/dist/chunks/{cac.Bmb60yM3.js → cac.B3UKR5lX.js} +20 -9
  7. package/dist/chunks/{cli-api.DwoCIT8I.js → cli-api.BFaocysU.js} +9193 -8366
  8. package/dist/chunks/{config.d.pC9164XK.d.ts → config.d.BAKb_cTu.d.ts} +2 -3
  9. package/dist/chunks/{coverage.DAUQBfjL.js → coverage.B8UAoQGx.js} +14 -2
  10. package/dist/chunks/{defaults.BOqNVLsY.js → defaults.BlJmGxXD.js} +2 -1
  11. package/dist/chunks/{global.d.DYf8kr_l.d.ts → global.d.x-ILCfAE.d.ts} +1 -2
  12. package/dist/chunks/{globals.AhCakrmA.js → globals.BSO_gjS1.js} +2 -2
  13. package/dist/chunks/{index.D3wDRGBz.js → index.C39wbgWx.js} +1 -1
  14. package/dist/chunks/{index.De5aIHUc.js → index.CoafDRze.js} +2218 -2181
  15. package/dist/chunks/{index.CEU66SQN.js → index.DmJHrI1k.js} +77 -3
  16. package/dist/chunks/{index.qcTcl_eM.js → index._gmCCuHk.js} +1 -1
  17. package/dist/chunks/{plugin.d.CTohQCcC.d.ts → plugin.d.D1im4ulu.d.ts} +1 -1
  18. package/dist/chunks/{reporters.d.DPe11uSn.d.ts → reporters.d.DFKgJkZE.d.ts} +32 -13
  19. package/dist/chunks/{rpc.d.CUhiUEld.d.ts → rpc.d.BFMWpdph.d.ts} +8 -1
  20. package/dist/chunks/{setup-common.BoY7R7rC.js → setup-common.Bafp3r-q.js} +1 -1
  21. package/dist/chunks/{test.CnO2BIt2.js → test.EDIwt4Yp.js} +19 -66
  22. package/dist/chunks/{worker.d.CiaQ1oon.d.ts → worker.d.KWMdtGFQ.d.ts} +2 -2
  23. package/dist/cli.js +3 -3
  24. package/dist/config.cjs +2 -1
  25. package/dist/config.d.ts +8 -7
  26. package/dist/config.js +1 -1
  27. package/dist/coverage.d.ts +5 -5
  28. package/dist/coverage.js +2 -2
  29. package/dist/index.d.ts +44 -11
  30. package/dist/index.js +2 -2
  31. package/dist/module-evaluator.d.ts +1 -1
  32. package/dist/node.d.ts +20 -10
  33. package/dist/node.js +22 -23
  34. package/dist/reporters.d.ts +5 -5
  35. package/dist/reporters.js +3 -3
  36. package/dist/runners.d.ts +1 -2
  37. package/dist/runners.js +1 -1
  38. package/dist/worker.d.ts +3 -3
  39. package/dist/worker.js +6 -5
  40. package/dist/workers/forks.js +6 -5
  41. package/dist/workers/runVmTests.js +11 -7
  42. package/dist/workers/threads.js +6 -5
  43. package/package.json +20 -13
package/LICENSE.md CHANGED
@@ -316,6 +316,37 @@ Repository: egoist/cac
316
316
 
317
317
  ---------------------------------------
318
318
 
319
+ ## convert-source-map
320
+ License: MIT
321
+ By: Thorsten Lorenz
322
+ Repository: git://github.com/thlorenz/convert-source-map.git
323
+
324
+ > Copyright 2013 Thorsten Lorenz.
325
+ > All rights reserved.
326
+ >
327
+ > Permission is hereby granted, free of charge, to any person
328
+ > obtaining a copy of this software and associated documentation
329
+ > files (the "Software"), to deal in the Software without
330
+ > restriction, including without limitation the rights to use,
331
+ > copy, modify, merge, publish, distribute, sublicense, and/or sell
332
+ > copies of the Software, and to permit persons to whom the
333
+ > Software is furnished to do so, subject to the following
334
+ > conditions:
335
+ >
336
+ > The above copyright notice and this permission notice shall be
337
+ > included in all copies or substantial portions of the Software.
338
+ >
339
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
340
+ > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
341
+ > OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
342
+ > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
343
+ > HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
344
+ > WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
345
+ > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
346
+ > OTHER DEALINGS IN THE SOFTWARE.
347
+
348
+ ---------------------------------------
349
+
319
350
  ## empathic
320
351
  License: MIT
321
352
  By: Luke Edwards
@@ -363,7 +394,7 @@ Repository: lydell/js-tokens
363
394
 
364
395
  > The MIT License (MIT)
365
396
  >
366
- > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Simon Lydell
397
+ > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
367
398
  >
368
399
  > Permission is hereby granted, free of charge, to any person obtaining a copy
369
400
  > of this software and associated documentation files (the "Software"), to deal
@@ -645,6 +676,90 @@ Repository: git+https://github.com/antfu/strip-literal.git
645
676
 
646
677
  ---------------------------------------
647
678
 
679
+ ## tinyhighlight
680
+ License: MIT
681
+ Repository: git+https://github.com/tinylibs/tinyhighlight.git
682
+
683
+ > # Tinyhighlight core license
684
+ >
685
+ > MIT License
686
+ >
687
+ > Copyright (c) 2023 Tinylibs
688
+ >
689
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
690
+ > of this software and associated documentation files (the "Software"), to deal
691
+ > in the Software without restriction, including without limitation the rights
692
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
693
+ > copies of the Software, and to permit persons to whom the Software is
694
+ > furnished to do so, subject to the following conditions:
695
+ >
696
+ > The above copyright notice and this permission notice shall be included in all
697
+ > copies or substantial portions of the Software.
698
+ >
699
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
700
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
701
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
702
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
703
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
704
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
705
+ > SOFTWARE.
706
+ >
707
+ > # Additionaly Tinyhighlight modifies code with the following licenses:
708
+ >
709
+ > MIT
710
+ >
711
+ > ## @babel/highlight
712
+ >
713
+ > MIT License
714
+ >
715
+ > Copyright (c) 2014-present Sebastian McKenzie and other contributors
716
+ >
717
+ > Permission is hereby granted, free of charge, to any person obtaining
718
+ > a copy of this software and associated documentation files (the
719
+ > "Software"), to deal in the Software without restriction, including
720
+ > without limitation the rights to use, copy, modify, merge, publish,
721
+ > distribute, sublicense, and/or sell copies of the Software, and to
722
+ > permit persons to whom the Software is furnished to do so, subject to
723
+ > the following conditions:
724
+ >
725
+ > The above copyright notice and this permission notice shall be
726
+ > included in all copies or substantial portions of the Software.
727
+ >
728
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
729
+ > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
730
+ > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
731
+ > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
732
+ > LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
733
+ > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
734
+ > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
735
+ >
736
+ > ## @babel/helper-validator-identifier
737
+ >
738
+ > MIT License
739
+ >
740
+ > Copyright (c) 2014-present Sebastian McKenzie and other contributors
741
+ >
742
+ > Permission is hereby granted, free of charge, to any person obtaining
743
+ > a copy of this software and associated documentation files (the
744
+ > "Software"), to deal in the Software without restriction, including
745
+ > without limitation the rights to use, copy, modify, merge, publish,
746
+ > distribute, sublicense, and/or sell copies of the Software, and to
747
+ > permit persons to whom the Software is furnished to do so, subject to
748
+ > the following conditions:
749
+ >
750
+ > The above copyright notice and this permission notice shall be
751
+ > included in all copies or substantial portions of the Software.
752
+ >
753
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
754
+ > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
755
+ > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
756
+ > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
757
+ > LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
758
+ > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
759
+ > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
760
+
761
+ ---------------------------------------
762
+
648
763
  ## type-detect
649
764
  License: MIT
650
765
  By: Jake Luer, Keith Cirkel, David Losert, Aleksey Shvayka, Lucas Fernandes da Costa, Grant Snodgrass, Jeremy Tice, Edward Betts, dvlsg, Amila Welihinda, Jake Champion, Miroslav Bajtoš
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.pC9164XK.js';
1
+ import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.BAKb_cTu.js';
2
2
  import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
4
  export { O as OTELCarrier, T as Traces } from './chunks/traces.d.402V_yFI.js';
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.BoY7R7rC.js';
1
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.Bafp3r-q.js';
2
2
  export { T as Traces } from './chunks/traces.CCmnQaNT.js';
3
3
  export { collectTests, startTests } from '@vitest/runner';
4
4
  import * as spyModule from '@vitest/spy';
@@ -1,6 +1,6 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import * as spyModule from '@vitest/spy';
3
- import { r as resolveTestRunner, a as resolveSnapshotEnvironment, s as setupChaiConfig } from './index.CEU66SQN.js';
3
+ import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.DmJHrI1k.js';
4
4
  import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.B95Mm0Iz.js';
5
5
  import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
6
6
  import { T as Traces } from './traces.CCmnQaNT.js';
@@ -8,15 +8,15 @@ import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
8
8
  import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.BK-u7y4N.js';
9
9
  import { performance as performance$1 } from 'node:perf_hooks';
10
10
  import { startTests, collectTests } from '@vitest/runner';
11
- import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.BoY7R7rC.js';
12
- import { g as globalExpect, v as vi } from './test.CnO2BIt2.js';
11
+ import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.Bafp3r-q.js';
12
+ import { g as globalExpect, v as vi } from './test.EDIwt4Yp.js';
13
13
  import { c as closeInspector } from './inspector.CvyFGlXm.js';
14
14
  import { createRequire } from 'node:module';
15
15
  import timers from 'node:timers';
16
16
  import timersPromises from 'node:timers/promises';
17
17
  import util from 'node:util';
18
18
  import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
19
- import { i as index } from './index.D3wDRGBz.js';
19
+ import { i as index } from './index.C39wbgWx.js';
20
20
  import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.DT4VyRyl.js';
21
21
 
22
22
  // this should only be used in Node
@@ -85,8 +85,12 @@ async function run(method, files, config, moduleRunner, environment, traces) {
85
85
  resetModules(workerState.evaluatedModules, true);
86
86
  }
87
87
  workerState.filepath = file.filepath;
88
- if (method === "run") await traces.$(`vitest.test.runner.${method}.module`, { attributes: { "code.file.path": file.filepath } }, () => startTests([file], testRunner));
89
- else await traces.$(`vitest.test.runner.${method}.module`, { attributes: { "code.file.path": file.filepath } }, () => collectTests([file], testRunner));
88
+ if (method === "run") {
89
+ const collectAsyncLeaks = config.detectAsyncLeaks ? detectAsyncLeaks(file.filepath, workerState.ctx.projectName) : void 0;
90
+ await traces.$(`vitest.test.runner.${method}.module`, { attributes: { "code.file.path": file.filepath } }, () => startTests([file], testRunner));
91
+ const leaks = await collectAsyncLeaks?.();
92
+ if (leaks?.length) workerState.rpc.onAsyncLeaks(leaks);
93
+ } else await traces.$(`vitest.test.runner.${method}.module`, { attributes: { "code.file.path": file.filepath } }, () => collectTests([file], testRunner));
90
94
  // reset after tests, because user might call `vi.setConfig` in setupFile
91
95
  vi.resetConfig();
92
96
  // mocks should not affect different files
@@ -1,6 +1,6 @@
1
1
  import { FileSpecification } from '@vitest/runner';
2
2
  import { O as OTELCarrier } from './traces.d.402V_yFI.js';
3
- import { T as TestExecutionMethod } from './worker.d.CiaQ1oon.js';
3
+ import { T as TestExecutionMethod } from './worker.d.KWMdtGFQ.js';
4
4
 
5
5
  type SerializedTestSpecification = [project: {
6
6
  name: string | undefined;
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import { normalize } from 'pathe';
4
4
  import c$2 from 'tinyrainbow';
5
5
  import { b as defaultPort, d as defaultBrowserPort } from './constants.CPYnjOGj.js';
6
- import { R as ReportersMap } from './index.De5aIHUc.js';
6
+ import { R as ReportersMap } from './index.CoafDRze.js';
7
7
  import assert from 'node:assert';
8
8
 
9
9
  function toArr(any) {
@@ -620,7 +620,7 @@ class CAC extends EventEmitter {
620
620
 
621
621
  const cac = (name = "") => new CAC(name);
622
622
 
623
- var version = "4.1.0-beta.3";
623
+ var version = "4.1.0-beta.4";
624
624
 
625
625
  const apiConfig = (port) => ({
626
626
  port: {
@@ -738,7 +738,7 @@ const cliOptionsConfig = {
738
738
  normalize: true
739
739
  },
740
740
  reporter: {
741
- description: "Coverage reporters to use. Visit [`coverage.reporter`](https://vitest.dev/config/#coverage-reporter) for more information (default: `[\"text\", \"html\", \"clover\", \"json\"]`)",
741
+ description: "Coverage reporters to use. Visit [`coverage.reporter`](https://vitest.dev/config/coverage#coverage-reporter) for more information (default: `[\"text\", \"html\", \"clover\", \"json\"]`)",
742
742
  argument: "<name>",
743
743
  subcommands: null,
744
744
  array: true
@@ -909,6 +909,7 @@ const cliOptionsConfig = {
909
909
  },
910
910
  passWithNoTests: { description: "Pass when no tests are found" },
911
911
  logHeapUsage: { description: "Show the size of heap for each test when running in node" },
912
+ detectAsyncLeaks: { description: "Detect asynchronous resources leaking from the test file (default: `false`)" },
912
913
  allowOnly: { description: "Allow tests and suites that are marked as only (default: `!process.env.CI`)" },
913
914
  dangerouslyIgnoreUnhandledErrors: { description: "Ignore any unhandled errors that occur" },
914
915
  shard: {
@@ -937,7 +938,7 @@ const cliOptionsConfig = {
937
938
  argument: "<seed>"
938
939
  },
939
940
  hooks: {
940
- description: "Changes the order in which hooks are executed. Accepted values are: \"stack\", \"list\" and \"parallel\". Visit [`sequence.hooks`](https://vitest.dev/config/#sequence-hooks) for more information (default: `\"parallel\"`)",
941
+ description: "Changes the order in which hooks are executed. Accepted values are: \"stack\", \"list\" and \"parallel\". Visit [`sequence.hooks`](https://vitest.dev/config/sequence#sequence-hooks) for more information (default: `\"parallel\"`)",
941
942
  argument: "<order>"
942
943
  },
943
944
  setupFiles: {
@@ -1257,6 +1258,8 @@ const cliOptionsConfig = {
1257
1258
  json: null,
1258
1259
  provide: null,
1259
1260
  filesOnly: null,
1261
+ staticParse: null,
1262
+ staticParseConcurrency: null,
1260
1263
  projects: null,
1261
1264
  watchTriggerPatterns: null,
1262
1265
  tags: null
@@ -1278,6 +1281,11 @@ const collectCliOptionsConfig = {
1278
1281
  argument: "[true/path]"
1279
1282
  },
1280
1283
  filesOnly: { description: "Print only test files with out the test cases" },
1284
+ staticParse: { description: "Parse files statically instead of running them to collect tests (default: false)" },
1285
+ staticParseConcurrency: {
1286
+ description: "How many tests to process at the same time (default: os.availableParallelism())",
1287
+ argument: "<limit>"
1288
+ },
1281
1289
  changed: {
1282
1290
  description: "Print only tests that are affected by the changed files (default: `false`)",
1283
1291
  argument: "[since]"
@@ -2293,11 +2301,11 @@ function normalizeCliOptions(cliFilters, argv) {
2293
2301
  }
2294
2302
  async function start(mode, cliFilters, options) {
2295
2303
  try {
2296
- const { startVitest } = await import('./cli-api.DwoCIT8I.js').then(function (n) { return n.q; });
2304
+ const { startVitest } = await import('./cli-api.BFaocysU.js').then(function (n) { return n.q; });
2297
2305
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2298
2306
  if (!ctx.shouldKeepServer()) await ctx.exit();
2299
2307
  } catch (e) {
2300
- const { errorBanner } = await import('./index.De5aIHUc.js').then(function (n) { return n.A; });
2308
+ const { errorBanner } = await import('./index.CoafDRze.js').then(function (n) { return n.A; });
2301
2309
  console.error(`\n${errorBanner("Startup Error")}`);
2302
2310
  console.error(e);
2303
2311
  console.error("\n\n");
@@ -2315,14 +2323,17 @@ async function init(project) {
2315
2323
  }
2316
2324
  async function collect(mode, cliFilters, options) {
2317
2325
  try {
2318
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.DwoCIT8I.js').then(function (n) { return n.q; });
2326
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BFaocysU.js').then(function (n) { return n.q; });
2319
2327
  const ctx = await prepareVitest(mode, {
2320
2328
  ...normalizeCliOptions(cliFilters, options),
2321
2329
  watch: false,
2322
2330
  run: true
2323
2331
  }, void 0, void 0, cliFilters);
2324
2332
  if (!options.filesOnly) {
2325
- const { testModules: tests, unhandledErrors: errors } = await ctx.collect(cliFilters.map(normalize));
2333
+ const { testModules: tests, unhandledErrors: errors } = await ctx.collect(cliFilters.map(normalize), {
2334
+ staticParse: options.staticParse,
2335
+ staticParseConcurrency: options.staticParseConcurrency
2336
+ });
2326
2337
  if (errors.length) {
2327
2338
  console.error("\nThere were unhandled errors during test collection");
2328
2339
  errors.forEach((e) => console.error(e));
@@ -2334,7 +2345,7 @@ async function collect(mode, cliFilters, options) {
2334
2345
  } else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
2335
2346
  await ctx.close();
2336
2347
  } catch (e) {
2337
- const { errorBanner } = await import('./index.De5aIHUc.js').then(function (n) { return n.A; });
2348
+ const { errorBanner } = await import('./index.CoafDRze.js').then(function (n) { return n.A; });
2338
2349
  console.error(`\n${errorBanner("Collect Error")}`);
2339
2350
  console.error(e);
2340
2351
  console.error("\n\n");