vitest 3.0.0-beta.1 → 3.0.0-beta.3

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 (46) hide show
  1. package/dist/browser.d.ts +12 -9
  2. package/dist/browser.js +2 -2
  3. package/dist/chunks/{RandomSequencer.gisBJ77r.js → RandomSequencer.C6x84bNN.js} +4 -3
  4. package/dist/chunks/{base.CkcgFVQd.js → base.CQ2VEtuH.js} +1 -1
  5. package/dist/chunks/{cac.CWCZimpS.js → cac.e7qW4xLT.js} +34 -18
  6. package/dist/chunks/{cli-api.BKUOv0Nc.js → cli-api.CWDlED-m.js} +1126 -537
  7. package/dist/chunks/{coverage.BoMDb1ip.js → coverage.BWeNbfBa.js} +4 -4
  8. package/dist/chunks/{creator.DcAcUhMD.js → creator.Ot9GlSGw.js} +16 -14
  9. package/dist/chunks/{environment.CT0jpO-1.d.ts → environment.d8YfPkTm.d.ts} +1 -3
  10. package/dist/chunks/{globals.DJTzb7B3.js → globals.BFncSRNA.js} +2 -2
  11. package/dist/chunks/{index.CkOJwybT.js → index.BBoOXW-l.js} +7 -2
  12. package/dist/chunks/{index.BqHViJW9.js → index.CkWmZCXU.js} +1 -1
  13. package/dist/chunks/{index.DKe7vK-G.js → index.CzkCSFCy.js} +670 -628
  14. package/dist/chunks/{reporters.BZbwTvrM.d.ts → reporters.DCiyjXOg.d.ts} +634 -532
  15. package/dist/chunks/{resolveConfig.3rGGWga5.js → resolveConfig.C1d7TK-U.js} +5560 -5541
  16. package/dist/chunks/{runBaseTests.C6huCAng.js → runBaseTests.qNWRkgHj.js} +11 -10
  17. package/dist/chunks/{setup-common.B5ClyS48.js → setup-common.Cp_bu5q3.js} +1 -1
  18. package/dist/chunks/types.BOjykUpq.d.ts +27 -0
  19. package/dist/chunks/{utils.CMUTX-p8.js → utils.Coei4Wlj.js} +1 -1
  20. package/dist/chunks/{vi.CZKezqeD.js → vi.S4Fq8wSo.js} +2 -1
  21. package/dist/chunks/{vite.DIfmneq0.d.ts → vite.CRSMFy31.d.ts} +1 -1
  22. package/dist/chunks/{worker.umPNbBNk.d.ts → worker.R-PA7DpW.d.ts} +1 -1
  23. package/dist/chunks/{worker.CmzGeuVD.d.ts → worker.XbtCXEXv.d.ts} +4 -3
  24. package/dist/cli.js +1 -1
  25. package/dist/config.cjs +1 -0
  26. package/dist/config.d.ts +6 -8
  27. package/dist/config.js +1 -0
  28. package/dist/coverage.d.ts +4 -6
  29. package/dist/coverage.js +33 -8
  30. package/dist/environments.d.ts +2 -2
  31. package/dist/execute.d.ts +2 -2
  32. package/dist/index.d.ts +11 -14
  33. package/dist/index.js +2 -2
  34. package/dist/node.d.ts +22 -17
  35. package/dist/node.js +66 -32
  36. package/dist/reporters.d.ts +4 -6
  37. package/dist/reporters.js +3 -3
  38. package/dist/runners.d.ts +2 -2
  39. package/dist/runners.js +3 -3
  40. package/dist/suite.d.ts +1 -1
  41. package/dist/workers/forks.js +1 -1
  42. package/dist/workers/runVmTests.js +7 -7
  43. package/dist/workers/threads.js +1 -1
  44. package/dist/workers.d.ts +3 -3
  45. package/dist/workers.js +1 -1
  46. package/package.json +15 -15
package/dist/browser.d.ts CHANGED
@@ -1,27 +1,26 @@
1
- import { b as CoverageProvider, c as CoverageProviderModule } from './chunks/reporters.BZbwTvrM.js';
1
+ import { b as CoverageProvider, c as CoverageProviderModule } from './chunks/reporters.DCiyjXOg.js';
2
2
  import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.BTPBhmK5.js';
3
3
  import * as spy$1 from '@vitest/spy';
4
4
  import * as _vitest_utils_diff from '@vitest/utils/diff';
5
5
  import { VitestExecutor } from './execute.js';
6
6
  export { collectTests, processError, startTests } from '@vitest/runner';
7
- import './chunks/environment.CT0jpO-1.js';
7
+ import './chunks/environment.d8YfPkTm.js';
8
+ import '@vitest/utils';
8
9
  import 'node:stream';
9
10
  import 'vite';
10
- import '@vitest/utils';
11
- import 'vite-node';
12
11
  import '@vitest/utils/source-map';
13
12
  import '@vitest/pretty-format';
14
13
  import '@vitest/snapshot';
14
+ import 'vite-node';
15
15
  import 'chai';
16
16
  import './chunks/benchmark.CFFwLv-O.js';
17
17
  import '@vitest/runner/utils';
18
18
  import 'tinybench';
19
- import 'vite-node/client';
20
- import 'vite-node/server';
21
19
  import '@vitest/snapshot/manager';
22
20
  import 'node:fs';
23
21
  import '@vitest/snapshot/environment';
24
- import './chunks/worker.CmzGeuVD.js';
22
+ import 'vite-node/client';
23
+ import './chunks/worker.XbtCXEXv.js';
25
24
  import 'node:vm';
26
25
  import '@vitest/mocker';
27
26
  import './chunks/mocker.cRtM890J.js';
@@ -52,9 +51,13 @@ interface Loader {
52
51
  isBrowser?: boolean;
53
52
  }
54
53
  declare function getCoverageProvider(options: SerializedCoverageConfig | undefined, loader: Loader): Promise<CoverageProvider | null>;
55
- declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: Loader): Promise<unknown>;
54
+ declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: Loader, runtimeOptions: {
55
+ isolate: boolean;
56
+ }): Promise<unknown>;
56
57
  declare function takeCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: Loader): Promise<unknown>;
57
- declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: Loader): Promise<unknown>;
58
+ declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: Loader, runtimeOptions: {
59
+ isolate: boolean;
60
+ }): Promise<unknown>;
58
61
 
59
62
  declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
60
63
  declare function loadDiffConfig(config: SerializedConfig, executor: VitestExecutor): Promise<_vitest_utils_diff.SerializedDiffOptions | undefined>;
package/dist/browser.js CHANGED
@@ -1,6 +1,6 @@
1
- export { g as getCoverageProvider, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.BoMDb1ip.js';
1
+ export { g as getCoverageProvider, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.BWeNbfBa.js';
2
2
  export { s as SpyModule } from './chunks/spy.Cf_4R5Oe.js';
3
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv } from './chunks/setup-common.B5ClyS48.js';
3
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv } from './chunks/setup-common.Cp_bu5q3.js';
4
4
  export { collectTests, processError, startTests } from '@vitest/runner';
5
5
  import '@vitest/spy';
6
6
  import '@vitest/snapshot';
@@ -1,4 +1,4 @@
1
- import 'std-env';
1
+ import { isCI } from 'std-env';
2
2
  import { writeFile, rm } from 'node:fs/promises';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks } from '@vitest/runner/utils';
@@ -21,6 +21,7 @@ const hash = crypto.hash ?? ((algorithm, data, outputEncoding) => crypto.createH
21
21
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
22
22
  const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
23
23
  const isWindows = (isNode || isDeno) && process.platform === "win32";
24
+ const isTTY = (isNode || isDeno) && process.stdout?.isTTY && !isCI;
24
25
 
25
26
  const REGEXP_WRAP_PREFIX = "$$vitest:";
26
27
  function getOutputFile(config, reporter) {
@@ -709,7 +710,7 @@ class Typechecker {
709
710
  if ("tasks" in task) {
710
711
  markTasks(task.tasks);
711
712
  }
712
- if (!task.result?.state && task.mode === "run") {
713
+ if (!task.result?.state && (task.mode === "run" || task.mode === "queued")) {
713
714
  task.result = {
714
715
  state: "pass"
715
716
  };
@@ -977,4 +978,4 @@ class RandomSequencer extends BaseSequencer {
977
978
  }
978
979
  }
979
980
 
980
- export { BaseSequencer as B, RandomSequencer as R, Typechecker as T, TypeCheckError as a, isNode as b, isDeno as c, getOutputFile as g, hash as h, isWindows as i, wrapSerializableConfig as w };
981
+ export { BaseSequencer as B, RandomSequencer as R, Typechecker as T, TypeCheckError as a, isTTY as b, getOutputFile as g, hash as h, isWindows as i, wrapSerializableConfig as w };
@@ -26,7 +26,7 @@ async function runBaseTests(method, state) {
26
26
  ));
27
27
  const [executor, { run }] = await Promise.all([
28
28
  startViteNode({ state, requestStubs: getDefaultRequestStubs() }),
29
- import('./runBaseTests.C6huCAng.js')
29
+ import('./runBaseTests.qNWRkgHj.js')
30
30
  ]);
31
31
  const fileSpecs = ctx.files.map(
32
32
  (f) => typeof f === "string" ? { filepath: f, testLocations: void 0 } : f
@@ -618,7 +618,7 @@ class CAC extends EventEmitter {
618
618
 
619
619
  const cac = (name = "") => new CAC(name);
620
620
 
621
- var version = "3.0.0-beta.1";
621
+ var version = "3.0.0-beta.3";
622
622
 
623
623
  const apiConfig = (port) => ({
624
624
  port: {
@@ -919,7 +919,7 @@ const cliOptionsConfig = {
919
919
  description: "Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)"
920
920
  },
921
921
  name: {
922
- description: "Run all tests in a specific browser. Some browsers are only available for specific providers (see `--browser.provider`). Visit [`browser.name`](https://vitest.dev/config/#browser-name) for more information",
922
+ description: "Run all tests in a specific browser. Some browsers are only available for specific providers (see `--browser.provider`). Visit [`browser.name`](https://vitest.dev/guide/browser/config/#browser-name) for more information",
923
923
  argument: "<name>"
924
924
  },
925
925
  headless: {
@@ -951,6 +951,10 @@ const cliOptionsConfig = {
951
951
  fileParallelism: {
952
952
  description: "Should browser test files run in parallel. Use `--browser.fileParallelism=false` to disable (default: `true`)"
953
953
  },
954
+ connectTimeout: {
955
+ description: "If connection to the browser takes longer, the test suite will fail (default: `60_000`)",
956
+ argument: "<timeout>"
957
+ },
954
958
  orchestratorScripts: null,
955
959
  testerScripts: null,
956
960
  commands: null,
@@ -958,11 +962,12 @@ const cliOptionsConfig = {
958
962
  screenshotDirectory: null,
959
963
  screenshotFailures: null,
960
964
  locators: null,
961
- testerHtmlPath: null
965
+ testerHtmlPath: null,
966
+ instances: null
962
967
  }
963
968
  },
964
969
  pool: {
965
- description: "Specify pool, if not running in the browser (default: `threads`)",
970
+ description: "Specify pool, if not running in the browser (default: `forks`)",
966
971
  argument: "<pool>",
967
972
  subcommands: null
968
973
  // don't support custom objects
@@ -1296,6 +1301,9 @@ const cliOptionsConfig = {
1296
1301
  printConsoleTrace: {
1297
1302
  description: "Always print console stack traces"
1298
1303
  },
1304
+ includeTaskLocation: {
1305
+ description: "Collect test and suite locations in the `location` property"
1306
+ },
1299
1307
  // CLI only options
1300
1308
  run: {
1301
1309
  description: "Disable watch mode"
@@ -1311,7 +1319,7 @@ const cliOptionsConfig = {
1311
1319
  description: "Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)"
1312
1320
  },
1313
1321
  mergeReports: {
1314
- description: "Paths to blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
1322
+ description: "Path to a blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
1315
1323
  argument: "[path]",
1316
1324
  transform(value) {
1317
1325
  if (!value || typeof value === "boolean") {
@@ -1350,7 +1358,6 @@ const cliOptionsConfig = {
1350
1358
  poolMatchGlobs: null,
1351
1359
  deps: null,
1352
1360
  name: null,
1353
- includeTaskLocation: null,
1354
1361
  snapshotEnvironment: null,
1355
1362
  compare: null,
1356
1363
  outputJson: null,
@@ -1538,11 +1545,20 @@ async function benchmark(cliFilters, options) {
1538
1545
  console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
1539
1546
  await start("benchmark", cliFilters, options);
1540
1547
  }
1541
- function normalizeCliOptions(argv) {
1548
+ function normalizeCliOptions(cliFilters, argv) {
1542
1549
  if (argv.exclude) {
1543
1550
  argv.cliExclude = toArray(argv.exclude);
1544
1551
  delete argv.exclude;
1545
1552
  }
1553
+ if (cliFilters.some((filter) => filter.includes(":"))) {
1554
+ argv.includeTaskLocation ??= true;
1555
+ }
1556
+ if (typeof argv.browser === "object" && !("enabled" in argv.browser)) {
1557
+ argv.browser.enabled = true;
1558
+ }
1559
+ if (typeof argv.typecheck?.only === "boolean") {
1560
+ argv.typecheck.enabled ??= true;
1561
+ }
1546
1562
  return argv;
1547
1563
  }
1548
1564
  async function start(mode, cliFilters, options) {
@@ -1551,13 +1567,13 @@ async function start(mode, cliFilters, options) {
1551
1567
  } catch {
1552
1568
  }
1553
1569
  try {
1554
- const { startVitest } = await import('./cli-api.BKUOv0Nc.js').then(function (n) { return n.e; });
1555
- const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
1556
- if (!ctx?.shouldKeepServer()) {
1557
- await ctx?.exit();
1570
+ const { startVitest } = await import('./cli-api.CWDlED-m.js').then(function (n) { return n.f; });
1571
+ const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1572
+ if (!ctx.shouldKeepServer()) {
1573
+ await ctx.exit();
1558
1574
  }
1559
1575
  } catch (e) {
1560
- const { divider } = await import('./utils.CMUTX-p8.js').then(function (n) { return n.u; });
1576
+ const { divider } = await import('./utils.Coei4Wlj.js').then(function (n) { return n.u; });
1561
1577
  console.error(`
1562
1578
  ${c.red(divider(c.bold(c.inverse(" Startup Error "))))}`);
1563
1579
  console.error(e);
@@ -1573,7 +1589,7 @@ async function init(project) {
1573
1589
  console.error(new Error('Only the "browser" project is supported. Use "vitest init browser" to create a new project.'));
1574
1590
  process.exit(1);
1575
1591
  }
1576
- const { create } = await import('./creator.DcAcUhMD.js');
1592
+ const { create } = await import('./creator.Ot9GlSGw.js');
1577
1593
  await create();
1578
1594
  }
1579
1595
  async function collect(mode, cliFilters, options) {
@@ -1582,14 +1598,14 @@ async function collect(mode, cliFilters, options) {
1582
1598
  } catch {
1583
1599
  }
1584
1600
  try {
1585
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BKUOv0Nc.js').then(function (n) { return n.e; });
1601
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.CWDlED-m.js').then(function (n) { return n.f; });
1586
1602
  const ctx = await prepareVitest(mode, {
1587
- ...normalizeCliOptions(options),
1603
+ ...normalizeCliOptions(cliFilters, options),
1588
1604
  watch: false,
1589
1605
  run: true
1590
1606
  });
1591
1607
  if (!options.filesOnly) {
1592
- const { tests, errors } = await ctx.collect(cliFilters.map(normalize));
1608
+ const { testModules: tests, unhandledErrors: errors } = await ctx.collect(cliFilters.map(normalize));
1593
1609
  if (errors.length) {
1594
1610
  console.error("\nThere were unhandled errors during test collection");
1595
1611
  errors.forEach((e) => console.error(e));
@@ -1599,12 +1615,12 @@ async function collect(mode, cliFilters, options) {
1599
1615
  }
1600
1616
  processCollected(ctx, tests, options);
1601
1617
  } else {
1602
- const files = await ctx.listFiles(cliFilters.map(normalize));
1618
+ const files = await ctx.getRelevantTestSpecifications(cliFilters.map(normalize));
1603
1619
  outputFileList(files, options);
1604
1620
  }
1605
1621
  await ctx.close();
1606
1622
  } catch (e) {
1607
- const { divider } = await import('./utils.CMUTX-p8.js').then(function (n) { return n.u; });
1623
+ const { divider } = await import('./utils.Coei4Wlj.js').then(function (n) { return n.u; });
1608
1624
  console.error(`
1609
1625
  ${c.red(divider(c.bold(c.inverse(" Collect Error "))))}`);
1610
1626
  console.error(e);