vitest 1.2.2 → 1.3.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 (57) hide show
  1. package/LICENSE.md +30 -2
  2. package/dist/browser.d.ts +3 -2
  3. package/dist/browser.js +2 -1
  4. package/dist/chunks/{integrations-globals.J_6tnlri.js → integrations-globals.THajbSRg.js} +6 -6
  5. package/dist/chunks/{runtime-runBaseTests.QReNMrJA.js → runtime-runBaseTests.9RbsHRbU.js} +9 -9
  6. package/dist/cli-wrapper.js +1 -1
  7. package/dist/cli.js +44 -131
  8. package/dist/config.cjs +1 -1
  9. package/dist/config.d.ts +1 -1
  10. package/dist/coverage.d.ts +6 -6
  11. package/dist/coverage.js +34 -3
  12. package/dist/environments.d.ts +1 -1
  13. package/dist/environments.js +1 -1
  14. package/dist/execute.d.ts +1 -1
  15. package/dist/execute.js +2 -2
  16. package/dist/index.d.ts +75 -78
  17. package/dist/index.js +7 -7
  18. package/dist/node.d.ts +12 -4
  19. package/dist/node.js +35 -27
  20. package/dist/{reporters-1evA5lom.d.ts → reporters-MmQN-57K.d.ts} +177 -61
  21. package/dist/reporters.d.ts +1 -1
  22. package/dist/reporters.js +20 -6
  23. package/dist/runners.d.ts +6 -6
  24. package/dist/runners.js +10 -10
  25. package/dist/{suite-ghspeorC.d.ts → suite-UrZdHRff.d.ts} +1 -1
  26. package/dist/suite.d.ts +2 -2
  27. package/dist/suite.js +2 -2
  28. package/dist/vendor/{base.QYERqzkH.js → base.N3JkKp7j.js} +1 -1
  29. package/dist/vendor/{base.Rmxiv35Y.js → base.Z38YsPLm.js} +2 -2
  30. package/dist/vendor/{benchmark.IlKmJkUU.js → benchmark.eeqk2rd8.js} +1 -1
  31. package/dist/vendor/{node.Zme77R4t.js → cac.wWT9ELdg.js} +9225 -5219
  32. package/dist/vendor/{constants.i1PoEnhr.js → constants.K-Wf1PUy.js} +3 -1
  33. package/dist/vendor/{execute.TxmaEFIQ.js → execute.27Kk4lQF.js} +23 -12
  34. package/dist/vendor/{index.cAUulNDf.js → index.8bPxjt7g.js} +6 -1
  35. package/dist/vendor/{index.RDKo8czB.js → index.9hqYxJUw.js} +7 -3
  36. package/dist/vendor/{environments.sU0TD7wX.js → index.GVFv9dZ0.js} +3 -0
  37. package/dist/vendor/{index.LgG0iblq.js → index.JZMafwT-.js} +4 -3
  38. package/dist/vendor/index.c1V_jzyZ.js +4927 -0
  39. package/dist/vendor/{index.rJjbcrrp.js → index.ir9i0ywP.js} +1 -1
  40. package/dist/vendor/{rpc.w4v8oCkK.js → rpc.joBhAkyK.js} +10 -1
  41. package/dist/vendor/setup-common.snyQUvE3.js +45 -0
  42. package/dist/vendor/{vi.PPwhENHF.js → vi.C5mroSoP.js} +2 -1
  43. package/dist/vendor/{vm.jVxKtN5R.js → vm.o1IruPAo.js} +25 -8
  44. package/dist/worker.js +5 -10
  45. package/dist/workers/forks.js +3 -3
  46. package/dist/workers/runVmTests.js +13 -9
  47. package/dist/workers/threads.js +3 -3
  48. package/dist/workers/vmForks.js +4 -4
  49. package/dist/workers/vmThreads.js +4 -4
  50. package/dist/workers.d.ts +3 -3
  51. package/dist/workers.js +8 -8
  52. package/globals.d.ts +2 -0
  53. package/jsdom.d.ts +6 -0
  54. package/package.json +24 -21
  55. package/dist/chunks/api-setup.srzH0bDf.js +0 -4808
  56. package/dist/vendor/reporters.cA9x-5v-.js +0 -2664
  57. package/dist/vendor/setup-common.C2iBd0K0.js +0 -29
package/LICENSE.md CHANGED
@@ -3,8 +3,7 @@ Vitest is released under the MIT license:
3
3
 
4
4
  MIT License
5
5
 
6
- Copyright (c) 2021-Present Anthony Fu <https://github.com/antfu>
7
- Copyright (c) 2021-Present Matias Capeletto <https://github.com/patak-dev>
6
+ Copyright (c) 2021-Present Vitest Team
8
7
 
9
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
10
9
  of this software and associated documentation files (the "Software"), to deal
@@ -306,6 +305,35 @@ Repository: micromatch/braces
306
305
 
307
306
  ---------------------------------------
308
307
 
308
+ ## cac
309
+ License: MIT
310
+ By: egoist
311
+ Repository: egoist/cac
312
+
313
+ > The MIT License (MIT)
314
+ >
315
+ > Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist)
316
+ >
317
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
318
+ > of this software and associated documentation files (the "Software"), to deal
319
+ > in the Software without restriction, including without limitation the rights
320
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
321
+ > copies of the Software, and to permit persons to whom the Software is
322
+ > furnished to do so, subject to the following conditions:
323
+ >
324
+ > The above copyright notice and this permission notice shall be included in
325
+ > all copies or substantial portions of the Software.
326
+ >
327
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
328
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
329
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
330
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
331
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
332
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
333
+ > THE SOFTWARE.
334
+
335
+ ---------------------------------------
336
+
309
337
  ## chai-subset
310
338
  License: MIT
311
339
  By: Andrii Shumada, Robert Herhold
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { processError, startTests } from '@vitest/runner';
2
- import { R as ResolvedConfig, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule } from './reporters-1evA5lom.js';
2
+ import { R as ResolvedConfig, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule } from './reporters-MmQN-57K.js';
3
3
  import { VitestExecutor } from './execute.js';
4
4
  import 'vite';
5
5
  import 'vite-node';
@@ -41,6 +41,7 @@ interface DiffOptions {
41
41
 
42
42
  declare function setupCommonEnv(config: ResolvedConfig): Promise<void>;
43
43
  declare function loadDiffConfig(config: ResolvedConfig, executor: VitestExecutor): Promise<DiffOptions | undefined>;
44
+ declare function loadSnapshotSerializers(config: ResolvedConfig, executor: VitestExecutor): Promise<void>;
44
45
 
45
46
  interface Loader {
46
47
  executeId: (id: string) => Promise<{
@@ -52,4 +53,4 @@ declare function startCoverageInsideWorker(options: CoverageOptions | undefined,
52
53
  declare function takeCoverageInsideWorker(options: CoverageOptions | undefined, loader: Loader): Promise<unknown>;
53
54
  declare function stopCoverageInsideWorker(options: CoverageOptions | undefined, loader: Loader): Promise<unknown>;
54
55
 
55
- export { getCoverageProvider, loadDiffConfig, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
56
+ export { getCoverageProvider, loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
package/dist/browser.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { processError, startTests } from '@vitest/runner';
2
- export { l as loadDiffConfig, s as setupCommonEnv } from './vendor/setup-common.C2iBd0K0.js';
2
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv } from './vendor/setup-common.snyQUvE3.js';
3
3
  export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor/coverage.E7sG1b3r.js';
4
4
  import '@vitest/utils';
5
+ import '@vitest/snapshot';
5
6
  import './vendor/run-once.Olz_Zkd8.js';
6
7
  import './vendor/global.CkGT_TMy.js';
@@ -1,15 +1,15 @@
1
- import { g as globalApis } from '../vendor/constants.i1PoEnhr.js';
2
- import { V as VitestIndex } from '../vendor/index.LgG0iblq.js';
1
+ import { g as globalApis } from '../vendor/constants.K-Wf1PUy.js';
2
+ import { V as VitestIndex } from '../vendor/index.JZMafwT-.js';
3
3
  import '@vitest/runner';
4
- import '../vendor/benchmark.IlKmJkUU.js';
4
+ import '../vendor/benchmark.eeqk2rd8.js';
5
5
  import '@vitest/runner/utils';
6
6
  import '@vitest/utils';
7
- import '../vendor/index.rJjbcrrp.js';
7
+ import '../vendor/index.ir9i0ywP.js';
8
8
  import 'pathe';
9
9
  import 'std-env';
10
10
  import '../vendor/global.CkGT_TMy.js';
11
11
  import '../vendor/run-once.Olz_Zkd8.js';
12
- import '../vendor/vi.PPwhENHF.js';
12
+ import '../vendor/vi.C5mroSoP.js';
13
13
  import 'chai';
14
14
  import '../vendor/_commonjsHelpers.jjO7Zipk.js';
15
15
  import '@vitest/expect';
@@ -17,7 +17,7 @@ import '@vitest/snapshot';
17
17
  import '@vitest/utils/error';
18
18
  import '../vendor/tasks.IknbGB2n.js';
19
19
  import '@vitest/utils/source-map';
20
- import '../vendor/base.QYERqzkH.js';
20
+ import '../vendor/base.N3JkKp7j.js';
21
21
  import '../vendor/date.Ns1pGd_X.js';
22
22
  import '@vitest/spy';
23
23
 
@@ -1,17 +1,17 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
- import '../vendor/index.rJjbcrrp.js';
4
- import { a as globalExpect, r as resetModules, v as vi } from '../vendor/vi.PPwhENHF.js';
3
+ import '../vendor/index.ir9i0ywP.js';
4
+ import { a as globalExpect, r as resetModules, v as vi } from '../vendor/vi.C5mroSoP.js';
5
5
  import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js';
6
- import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.RDKo8czB.js';
6
+ import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.9hqYxJUw.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import util from 'node:util';
9
9
  import timers from 'node:timers';
10
10
  import { isatty } from 'node:tty';
11
11
  import { installSourcemapsSupport } from 'vite-node/source-map';
12
12
  import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
13
- import { V as VitestIndex } from '../vendor/index.LgG0iblq.js';
14
- import { s as setupCommonEnv } from '../vendor/setup-common.C2iBd0K0.js';
13
+ import { V as VitestIndex } from '../vendor/index.JZMafwT-.js';
14
+ import { s as setupCommonEnv } from '../vendor/setup-common.snyQUvE3.js';
15
15
  import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
16
16
  import 'pathe';
17
17
  import 'std-env';
@@ -23,15 +23,15 @@ import '@vitest/snapshot';
23
23
  import '@vitest/utils/error';
24
24
  import '../vendor/tasks.IknbGB2n.js';
25
25
  import '@vitest/utils/source-map';
26
- import '../vendor/base.QYERqzkH.js';
26
+ import '../vendor/base.N3JkKp7j.js';
27
27
  import '../vendor/date.Ns1pGd_X.js';
28
28
  import '@vitest/spy';
29
29
  import '@vitest/snapshot/environment';
30
30
  import '../path.js';
31
31
  import 'node:url';
32
- import '../vendor/rpc.w4v8oCkK.js';
33
- import '../vendor/index.cAUulNDf.js';
34
- import '../vendor/benchmark.IlKmJkUU.js';
32
+ import '../vendor/rpc.joBhAkyK.js';
33
+ import '../vendor/index.8bPxjt7g.js';
34
+ import '../vendor/benchmark.eeqk2rd8.js';
35
35
  import '../vendor/run-once.Olz_Zkd8.js';
36
36
 
37
37
  let globalSetup = false;
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath } from 'node:url';
2
2
  import c from 'picocolors';
3
3
  import { execa } from 'execa';
4
- import { E as EXIT_CODE_RESTART } from './vendor/constants.i1PoEnhr.js';
4
+ import { E as EXIT_CODE_RESTART } from './vendor/constants.K-Wf1PUy.js';
5
5
 
6
6
  const ENTRY = new URL("./cli.js", import.meta.url);
7
7
  const NODE_ARGS = [
package/dist/cli.js CHANGED
@@ -1,154 +1,67 @@
1
- import { normalize } from 'pathe';
2
- import cac from 'cac';
3
- import c from 'picocolors';
4
- import { v as version, s as startVitest } from './vendor/node.Zme77R4t.js';
5
- import './vendor/index.rJjbcrrp.js';
6
- import { d as divider } from './vendor/reporters.cA9x-5v-.js';
7
- import { t as toArray } from './vendor/base.QYERqzkH.js';
8
- import 'vite';
1
+ import { d as createCLI } from './vendor/cac.wWT9ELdg.js';
2
+ import 'pathe';
3
+ import 'events';
4
+ import 'picocolors';
5
+ import './vendor/index.ir9i0ywP.js';
6
+ import 'std-env';
7
+ import '@vitest/runner/utils';
8
+ import '@vitest/utils';
9
+ import './vendor/global.CkGT_TMy.js';
10
+ import './vendor/index.c1V_jzyZ.js';
11
+ import 'node:fs';
12
+ import 'node:perf_hooks';
13
+ import './chunks/runtime-console.Iloo9fIt.js';
14
+ import 'node:stream';
15
+ import 'node:console';
9
16
  import 'node:path';
17
+ import './vendor/date.Ns1pGd_X.js';
18
+ import './vendor/base.N3JkKp7j.js';
19
+ import './vendor/tasks.IknbGB2n.js';
20
+ import '@vitest/utils/source-map';
21
+ import 'node:os';
22
+ import 'node:module';
23
+ import 'node:fs/promises';
24
+ import 'execa';
10
25
  import 'node:url';
26
+ import 'path';
27
+ import 'fs';
28
+ import 'module';
29
+ import 'vite';
30
+ import 'acorn-walk';
11
31
  import 'node:process';
12
- import 'node:fs';
13
- import './vendor/constants.i1PoEnhr.js';
14
32
  import './vendor/_commonjsHelpers.jjO7Zipk.js';
33
+ import 'assert';
34
+ import 'node:crypto';
35
+ import 'vite-node/utils';
36
+ import './vendor/constants.K-Wf1PUy.js';
37
+ import './vendor/coverage.E7sG1b3r.js';
38
+ import './vendor/index.GVFv9dZ0.js';
15
39
  import 'os';
16
- import 'path';
17
40
  import './vendor/index.xL8XjTLv.js';
18
41
  import 'util';
19
42
  import 'stream';
20
- import 'events';
21
- import 'fs';
22
43
  import 'vite-node/client';
23
44
  import '@vitest/snapshot/manager';
24
45
  import 'vite-node/server';
25
- import './vendor/coverage.E7sG1b3r.js';
26
46
  import './path.js';
47
+ import './vendor/index.8bPxjt7g.js';
48
+ import 'zlib';
49
+ import 'buffer';
50
+ import 'crypto';
51
+ import 'https';
52
+ import 'http';
53
+ import 'net';
54
+ import 'tls';
55
+ import 'url';
27
56
  import 'node:v8';
28
- import 'node:os';
29
57
  import 'node:events';
30
58
  import 'tinypool';
31
- import './vendor/index.cAUulNDf.js';
32
59
  import 'node:worker_threads';
33
- import '@vitest/utils';
34
- import 'node:fs/promises';
35
- import 'node:perf_hooks';
36
- import 'execa';
37
- import '@vitest/utils/source-map';
38
- import 'module';
39
- import 'acorn-walk';
40
- import '@vitest/runner/utils';
41
60
  import 'local-pkg';
42
- import 'std-env';
43
- import 'node:crypto';
44
- import 'vite-node/utils';
45
- import 'assert';
46
61
  import 'magic-string';
47
62
  import '@vitest/utils/ast';
48
63
  import 'strip-literal';
49
- import 'node:module';
50
- import './vendor/environments.sU0TD7wX.js';
51
- import 'node:console';
52
64
  import 'node:readline';
53
65
  import 'readline';
54
- import './vendor/global.CkGT_TMy.js';
55
- import './chunks/runtime-console.Iloo9fIt.js';
56
- import 'node:stream';
57
- import './vendor/date.Ns1pGd_X.js';
58
- import './vendor/tasks.IknbGB2n.js';
59
66
 
60
- const cli = cac("vitest");
61
- 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", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp 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("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--coverage.all", "Whether to include all files, including the untested ones into report", { default: true }).option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--workspace <path>", "Path to a workspace configuration file").option("--isolate", "Run every test file in isolation. To disable isolation, use --no-isolate (default: true)").option("--globals", "Inject apis globally").option("--dom", "Mock browser API with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--pool <pool>", "Specify pool, if not running in the browser (default: threads)").option("--poolOptions <options>", "Specify pool options").option("--poolOptions.threads.isolate", "Isolate tests in threads pool (default: true)").option("--poolOptions.forks.isolate", "Isolate tests in forks pool (default: true)").option("--fileParallelism", "Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)").option("--maxWorkers <workers>", "Maximum number of workers to run tests in").option("--minWorkers <workers>", "Minimum number of workers to run tests in").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").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)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order, use --sequence.concurrent to run tests in parallel)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed (default: 0)").option("--retry <times>", "Retry the test specific number of times if it fails (default: 0)").option("--diff <path>", "Path to a diff config that will be used to generate diff interface").option("--exclude <glob>", "Additional file globs to be excluded from test").option("--expand-snapshot-diff", "Show full diff when snapshot fails").option("--disable-console-intercept", "Disable automatic interception of console logging (default: `false`)").option("--typecheck [options]", "Custom options for typecheck pool").option("--typecheck.enabled", "Enable typechecking alongside tests (default: false)").option("--typecheck.only", "Run only typecheck tests. This automatically enables typecheck (default: false)").option("--project <name>", "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2").help();
62
- cli.command("run [...filters]").action(run);
63
- cli.command("related [...filters]").action(runRelated);
64
- cli.command("watch [...filters]").action(watch);
65
- cli.command("dev [...filters]").action(watch);
66
- cli.command("bench [...filters]").action(benchmark);
67
- cli.command("typecheck [...filters]").action(() => {
68
- throw new Error(`Running typecheck via "typecheck" command is removed. Please use "--typecheck" to run your regular tests alongside typechecking, or "--typecheck.only" to run only typecheck tests.`);
69
- });
70
- cli.command("[...filters]").action((filters, options) => start("test", filters, options));
71
- try {
72
- cli.parse();
73
- } catch (originalError) {
74
- const fullArguments = cli.rawArgs.join(" ");
75
- const conflictingArgs = [];
76
- for (const arg of cli.rawArgs) {
77
- if (arg.startsWith("--") && !arg.includes(".") && fullArguments.includes(`${arg}.`)) {
78
- const dotArgs = cli.rawArgs.filter((rawArg) => rawArg.startsWith(arg) && rawArg.includes("."));
79
- conflictingArgs.push({ arg, dotArgs });
80
- }
81
- }
82
- if (conflictingArgs.length === 0)
83
- throw originalError;
84
- const error = conflictingArgs.map(({ arg, dotArgs }) => `A boolean argument "${arg}" was used with dot notation arguments "${dotArgs.join(" ")}".
85
- Please specify the "${arg}" argument with dot notation as well: "${arg}.enabled"`).join("\n");
86
- throw new Error(error);
87
- }
88
- async function runRelated(relatedFiles, argv) {
89
- argv.related = relatedFiles;
90
- argv.passWithNoTests ?? (argv.passWithNoTests = true);
91
- await start("test", [], argv);
92
- }
93
- async function watch(cliFilters, options) {
94
- options.watch = true;
95
- await start("test", cliFilters, options);
96
- }
97
- async function run(cliFilters, options) {
98
- options.run = true;
99
- await start("test", cliFilters, options);
100
- }
101
- async function benchmark(cliFilters, options) {
102
- console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
103
- await start("benchmark", cliFilters, options);
104
- }
105
- function normalizeCliOptions(argv) {
106
- if (argv.root)
107
- argv.root = normalize(argv.root);
108
- else
109
- delete argv.root;
110
- if (argv.config)
111
- argv.config = normalize(argv.config);
112
- else
113
- delete argv.config;
114
- if (argv.workspace)
115
- argv.workspace = normalize(argv.workspace);
116
- else
117
- delete argv.workspace;
118
- if (argv.dir)
119
- argv.dir = normalize(argv.dir);
120
- else
121
- delete argv.dir;
122
- if (argv.exclude) {
123
- argv.cliExclude = toArray(argv.exclude);
124
- delete argv.exclude;
125
- }
126
- if (argv.coverage) {
127
- const coverage = argv.coverage;
128
- if (coverage.exclude)
129
- coverage.exclude = toArray(coverage.exclude);
130
- if (coverage.include)
131
- coverage.include = toArray(coverage.include);
132
- if (coverage.ignoreClassMethods)
133
- coverage.ignoreClassMethods = toArray(coverage.ignoreClassMethods);
134
- }
135
- return argv;
136
- }
137
- async function start(mode, cliFilters, options) {
138
- try {
139
- process.title = "node (vitest)";
140
- } catch {
141
- }
142
- try {
143
- const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
144
- if (!(ctx == null ? void 0 : ctx.shouldKeepServer()))
145
- await (ctx == null ? void 0 : ctx.exit());
146
- return ctx;
147
- } catch (e) {
148
- console.error(`
149
- ${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
150
- console.error(e);
151
- console.error("\n\n");
152
- process.exit(1);
153
- }
154
- }
67
+ createCLI().parse();
package/dist/config.cjs CHANGED
@@ -119,7 +119,7 @@ function defineWorkspace(config) {
119
119
  return config;
120
120
  }
121
121
 
122
- Object.defineProperty(exports, 'mergeConfig', {
122
+ Object.defineProperty(exports, "mergeConfig", {
123
123
  enumerable: true,
124
124
  get: function () { return vite.mergeConfig; }
125
125
  });
package/dist/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
2
- export { aw as UserConfigExport, av as UserConfigFn, at as UserConfigFnObject, au as UserConfigFnPromise, ay as UserProjectConfigExport, ax as UserProjectConfigFn, a0 as UserWorkspaceConfig, aC as configDefaults, aF as coverageConfigDefaults, aE as defaultExclude, aD as defaultInclude, az as defineConfig, aA as defineProject, aB as defineWorkspace, aG as extraInlineDeps } from './reporters-1evA5lom.js';
2
+ export { ax as UserConfigExport, aw as UserConfigFn, au as UserConfigFnObject, av as UserConfigFnPromise, az as UserProjectConfigExport, ay as UserProjectConfigFn, a1 as UserWorkspaceConfig, aD as configDefaults, aG as coverageConfigDefaults, aF as defaultExclude, aE as defaultInclude, aA as defineConfig, aB as defineProject, aC as defineWorkspace, aH as extraInlineDeps } from './reporters-MmQN-57K.js';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
5
5
  import '@vitest/snapshot';
@@ -1,4 +1,4 @@
1
- import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-1evA5lom.js';
1
+ import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-MmQN-57K.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -128,13 +128,11 @@ declare class BaseCoverageProvider {
128
128
  /**
129
129
  * Check if current coverage is above configured thresholds and bump the thresholds if needed
130
130
  */
131
- updateThresholds({ thresholds: allThresholds, perFile, configurationFile }: {
131
+ updateThresholds({ thresholds: allThresholds, perFile, configurationFile, onUpdate }: {
132
132
  thresholds: ResolvedThreshold[];
133
133
  perFile?: boolean;
134
- configurationFile: {
135
- read(): unknown;
136
- write(): void;
137
- };
134
+ configurationFile: unknown;
135
+ onUpdate: () => void;
138
136
  }): void;
139
137
  /**
140
138
  * Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
@@ -157,6 +155,8 @@ declare class BaseCoverageProvider {
157
155
  * Resolve reporters from various configuration options
158
156
  */
159
157
  resolveReporters(configReporters: NonNullable<BaseCoverageOptions['reporter']>): ResolvedCoverageOptions['reporter'];
158
+ hasTerminalReporter(reporters: ResolvedCoverageOptions['reporter']): boolean;
159
+ toSlices<T>(array: T[], size: number): T[][];
160
160
  }
161
161
 
162
162
  export { BaseCoverageProvider };
package/dist/coverage.js CHANGED
@@ -10,9 +10,9 @@ class BaseCoverageProvider {
10
10
  /**
11
11
  * Check if current coverage is above configured thresholds and bump the thresholds if needed
12
12
  */
13
- updateThresholds({ thresholds: allThresholds, perFile, configurationFile }) {
13
+ updateThresholds({ thresholds: allThresholds, perFile, configurationFile, onUpdate }) {
14
14
  let updatedThresholds = false;
15
- const config = configurationFile.read();
15
+ const config = resolveConfig(configurationFile);
16
16
  assertConfigurationModule(config);
17
17
  for (const { coverageMap, thresholds, name } of allThresholds) {
18
18
  const summaries = perFile ? coverageMap.files().map((file) => coverageMap.fileCoverageFor(file).toSummary()) : [coverageMap.getCoverageSummary()];
@@ -37,7 +37,7 @@ class BaseCoverageProvider {
37
37
  }
38
38
  if (updatedThresholds) {
39
39
  console.log("Updating thresholds to configuration file. You may want to push with updated coverage thresholds.");
40
- configurationFile.write();
40
+ onUpdate();
41
41
  }
42
42
  }
43
43
  /**
@@ -131,6 +131,21 @@ class BaseCoverageProvider {
131
131
  }
132
132
  return resolvedReporters;
133
133
  }
134
+ hasTerminalReporter(reporters) {
135
+ return reporters.some(([reporter]) => reporter === "text" || reporter === "text-summary" || reporter === "text-lcov" || reporter === "teamcity");
136
+ }
137
+ toSlices(array, size) {
138
+ return array.reduce((chunks, item) => {
139
+ const index = Math.max(0, chunks.length - 1);
140
+ const lastChunk = chunks[index] || [];
141
+ chunks[index] = lastChunk;
142
+ if (lastChunk.length >= size)
143
+ chunks.push([item]);
144
+ else
145
+ lastChunk.push(item);
146
+ return chunks;
147
+ }, []);
148
+ }
134
149
  }
135
150
  function resolveGlobThresholds(thresholds) {
136
151
  if (!thresholds || typeof thresholds !== "object")
@@ -151,5 +166,21 @@ function assertConfigurationModule(config) {
151
166
  throw new Error(`Unable to parse thresholds from configuration file: ${message}`);
152
167
  }
153
168
  }
169
+ function resolveConfig(configModule) {
170
+ const mod = configModule.exports.default;
171
+ try {
172
+ if (mod.$type === "object")
173
+ return mod;
174
+ if (mod.$type === "function-call") {
175
+ if (mod.$args[0].$type === "object")
176
+ return mod.$args[0];
177
+ if (mod.$args[0].$type === "arrow-function-expression" && mod.$args[0].$body.$type === "object")
178
+ return mod.$args[0].$body;
179
+ }
180
+ } catch (error) {
181
+ throw new Error(error instanceof Error ? error.message : String(error));
182
+ }
183
+ throw new Error("Failed to update coverage thresholds. Configuration file is too complex.");
184
+ }
154
185
 
155
186
  export { BaseCoverageProvider };
@@ -1,4 +1,4 @@
1
- import { E as Environment } from './reporters-1evA5lom.js';
1
+ import { E as Environment } from './reporters-MmQN-57K.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -1,2 +1,2 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './vendor/environments.sU0TD7wX.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.GVFv9dZ0.js';
2
2
  import 'node:console';
package/dist/execute.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import vm from 'node:vm';
2
2
  import { ViteNodeRunner } from 'vite-node/client';
3
3
  import { ViteNodeRunnerOptions } from 'vite-node';
4
- import { aq as PendingSuiteMock, ar as MockFactory, f as RuntimeRPC, p as WorkerGlobalState, as as MockMap } from './reporters-1evA5lom.js';
4
+ import { ar as PendingSuiteMock, as as MockFactory, e as RuntimeRPC, W as WorkerGlobalState, at as MockMap } from './reporters-MmQN-57K.js';
5
5
  import 'vite';
6
6
  import '@vitest/runner';
7
7
  import '@vitest/snapshot';
package/dist/execute.js CHANGED
@@ -1,4 +1,4 @@
1
- export { V as VitestExecutor } from './vendor/execute.TxmaEFIQ.js';
1
+ export { V as VitestExecutor } from './vendor/execute.27Kk4lQF.js';
2
2
  import 'node:vm';
3
3
  import 'node:url';
4
4
  import 'vite-node/client';
@@ -8,4 +8,4 @@ import '@vitest/utils/error';
8
8
  import './path.js';
9
9
  import 'node:fs';
10
10
  import '@vitest/utils';
11
- import './vendor/base.QYERqzkH.js';
11
+ import './vendor/base.N3JkKp7j.js';