vitest 3.0.2 → 3.0.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.
@@ -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.2";
621
+ var version = "3.0.3";
622
622
 
623
623
  const apiConfig = (port) => ({
624
624
  port: {
@@ -1567,7 +1567,7 @@ async function start(mode, cliFilters, options) {
1567
1567
  } catch {
1568
1568
  }
1569
1569
  try {
1570
- const { startVitest } = await import('./cli-api.B7hOUwun.js').then(function (n) { return n.f; });
1570
+ const { startVitest } = await import('./cli-api.BaY17YBo.js').then(function (n) { return n.f; });
1571
1571
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1572
1572
  if (!ctx.shouldKeepServer()) {
1573
1573
  await ctx.exit();
@@ -1598,7 +1598,7 @@ async function collect(mode, cliFilters, options) {
1598
1598
  } catch {
1599
1599
  }
1600
1600
  try {
1601
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.B7hOUwun.js').then(function (n) { return n.f; });
1601
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BaY17YBo.js').then(function (n) { return n.f; });
1602
1602
  const ctx = await prepareVitest(mode, {
1603
1603
  ...normalizeCliOptions(cliFilters, options),
1604
1604
  watch: false,
@@ -10,9 +10,9 @@ import { generateFileHash, createFileTask, limitConcurrency, hasFailed, getTasks
10
10
  import { SnapshotManager } from '@vitest/snapshot/manager';
11
11
  import { ViteNodeRunner } from 'vite-node/client';
12
12
  import { ViteNodeServer } from 'vite-node/server';
13
- import { v as version$1 } from './cac.CHB7MTUk.js';
13
+ import { v as version$1 } from './cac.Cfe6a4o8.js';
14
14
  import { c as createBirpc } from './index.TH3f4LSA.js';
15
- import { s as stringify, p as parse, g as printError, h as generateCodeFrame, R as ReportersMap, b as BenchmarkReportsMap, i as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.DyQPL4DO.js';
15
+ import { s as stringify, p as parse, g as printError, h as generateCodeFrame, R as ReportersMap, b as BenchmarkReportsMap, i as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.CvtAP0DU.js';
16
16
  import require$$0$2 from 'stream';
17
17
  import require$$0 from 'zlib';
18
18
  import require$$0$1 from 'buffer';
@@ -26,7 +26,7 @@ import require$$7 from 'url';
26
26
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
27
27
  import { parseErrorStacktrace } from '@vitest/utils/source-map';
28
28
  import { distDir, rootDir } from '../path.js';
29
- import { R as RandomSequencer, i as isPackageExists, e as requireMicromatch, h as hash, V as VitestCache, f as configDefaults, g as getFilePoolName, j as isBrowserEnabled, m as mm, a as resolveConfig, k as groupBy, w as wildcardPatternToRegExp, l as createPool, b as resolveApiServerConfig, s as stdout } from './resolveConfig.DATSOo7x.js';
29
+ import { R as RandomSequencer, i as isPackageExists, e as requireMicromatch, h as hash, V as VitestCache, f as configDefaults, g as getFilePoolName, j as isBrowserEnabled, m as mm, a as resolveConfig, k as groupBy, w as wildcardPatternToRegExp, l as createPool, b as resolveApiServerConfig, s as stdout } from './resolveConfig.9CnFfuqj.js';
30
30
  import { i as isTTY, b as isWindows, c as convertTasksToEvents } from './typechecker.ChNaIV36.js';
31
31
  import { Console } from 'node:console';
32
32
  import c from 'tinyrainbow';
@@ -984,7 +984,7 @@ ${JSON.stringify({ test: { reporters: [["default", { summary: false }]] } }, nul
984
984
  }
985
985
  }
986
986
 
987
- const DEFAULT_RENDER_INTERVAL = 16;
987
+ const DEFAULT_RENDER_INTERVAL_MS = 1e3;
988
988
  const ESC = "\x1B[";
989
989
  const CLEAR_LINE = `${ESC}K`;
990
990
  const MOVE_CURSOR_ONE_ROW_UP = `${ESC}1A`;
@@ -995,12 +995,13 @@ class WindowRenderer {
995
995
  streams;
996
996
  buffer = [];
997
997
  renderInterval = undefined;
998
+ renderScheduled = false;
998
999
  windowHeight = 0;
999
1000
  finished = false;
1000
1001
  cleanups = [];
1001
1002
  constructor(options) {
1002
1003
  this.options = {
1003
- interval: DEFAULT_RENDER_INTERVAL,
1004
+ interval: DEFAULT_RENDER_INTERVAL_MS,
1004
1005
  ...options
1005
1006
  };
1006
1007
  this.streams = {
@@ -1019,7 +1020,7 @@ class WindowRenderer {
1019
1020
  }
1020
1021
  start() {
1021
1022
  this.finished = false;
1022
- this.renderInterval = setInterval(() => this.flushBuffer(), this.options.interval).unref();
1023
+ this.renderInterval = setInterval(() => this.schedule(), this.options.interval).unref();
1023
1024
  }
1024
1025
  stop() {
1025
1026
  this.cleanups.splice(0).map((fn) => fn());
@@ -1034,6 +1035,18 @@ class WindowRenderer {
1034
1035
  this.flushBuffer();
1035
1036
  clearInterval(this.renderInterval);
1036
1037
  }
1038
+ /**
1039
+ * Queue new render update
1040
+ */
1041
+ schedule() {
1042
+ if (!this.renderScheduled) {
1043
+ this.renderScheduled = true;
1044
+ this.flushBuffer();
1045
+ setTimeout(() => {
1046
+ this.renderScheduled = false;
1047
+ }, 100).unref();
1048
+ }
1049
+ }
1037
1050
  flushBuffer() {
1038
1051
  if (this.buffer.length === 0) {
1039
1052
  return this.render();
@@ -1170,6 +1183,7 @@ class SummaryReporter {
1170
1183
  this.removeTestModule(finished);
1171
1184
  }
1172
1185
  this.runningModules.set(module.id, initializeStats(module));
1186
+ this.renderer.schedule();
1173
1187
  }
1174
1188
  onTestModuleCollected(module) {
1175
1189
  let stats = this.runningModules.get(module.id);
@@ -1181,6 +1195,7 @@ class SummaryReporter {
1181
1195
  this.tests.total += total;
1182
1196
  stats.total = total;
1183
1197
  this.maxParallelTests = Math.max(this.maxParallelTests, this.runningModules.size);
1198
+ this.renderer.schedule();
1184
1199
  }
1185
1200
  onHookStart(options) {
1186
1201
  const stats = this.getHookStats(options);
@@ -1249,6 +1264,7 @@ class SummaryReporter {
1249
1264
  } else if (!result?.state || result?.state === "skipped") {
1250
1265
  this.tests.skipped++;
1251
1266
  }
1267
+ this.renderer.schedule();
1252
1268
  }
1253
1269
  onTestModuleEnd(module) {
1254
1270
  const state = module.state();
@@ -1270,6 +1286,7 @@ class SummaryReporter {
1270
1286
  } else {
1271
1287
  this.removeTestModule(module.id);
1272
1288
  }
1289
+ this.renderer.schedule();
1273
1290
  }
1274
1291
  getHookStats({ entity }) {
1275
1292
  if (!this.options.verbose) {
@@ -1467,10 +1484,12 @@ class DotReporter extends BaseReporter {
1467
1484
  return;
1468
1485
  }
1469
1486
  this.tests.set(test.id, test.result().state || "run");
1487
+ this.renderer?.schedule();
1470
1488
  }
1471
1489
  onTestCaseResult(test) {
1472
1490
  this.finishedTests.add(test.id);
1473
1491
  this.tests.set(test.id, test.result().state || "skipped");
1492
+ this.renderer?.schedule();
1474
1493
  }
1475
1494
  onTestModuleEnd() {
1476
1495
  if (!this.isTTY) {
@@ -1494,6 +1513,7 @@ class DotReporter extends BaseReporter {
1494
1513
  states.push(state);
1495
1514
  }
1496
1515
  this.ctx.logger.log(formatTests(states));
1516
+ this.renderer?.schedule();
1497
1517
  }
1498
1518
  createSummary() {
1499
1519
  return [
@@ -7953,20 +7953,21 @@ function resolveConfig(mode, options, viteConfig, logger) {
7953
7953
  const browser = resolved.browser;
7954
7954
  if (browser.enabled) {
7955
7955
  if (!browser.name && !browser.instances) {
7956
- throw new Error(`Vitest Browser Mode requires "browser.name" (deprecated) or "browser.instances" options, none were set.`);
7957
- }
7958
- const configs = browser.instances;
7959
- if (browser.name && browser.instances) {
7960
- browser.instances = browser.instances.filter((instance) => instance.browser === browser.name);
7961
- }
7962
- if (browser.instances && !browser.instances.length) {
7963
- throw new Error([
7964
- `"browser.instances" was set in the config, but the array is empty. Define at least one browser config.`,
7965
- browser.name && configs?.length ? ` The "browser.name" was set to "${browser.name}" which filtered all configs (${configs.map((c2) => c2.browser).join(", ")}). Did you mean to use another name?` : ""
7966
- ].join(""));
7956
+ browser.enabled = false;
7957
+ } else {
7958
+ const instances = browser.instances;
7959
+ if (browser.name && browser.instances) {
7960
+ browser.instances = browser.instances.filter((instance) => instance.browser === browser.name);
7961
+ }
7962
+ if (browser.instances && !browser.instances.length) {
7963
+ throw new Error([
7964
+ `"browser.instances" was set in the config, but the array is empty. Define at least one browser config.`,
7965
+ browser.name && instances?.length ? ` The "browser.name" was set to "${browser.name}" which filtered all configs (${instances.map((c2) => c2.browser).join(", ")}). Did you mean to use another name?` : ""
7966
+ ].join(""));
7967
+ }
7967
7968
  }
7968
7969
  }
7969
- const playwrightChromiumOnly = browser.provider === "playwright" && (browser.name === "chromium" || browser.instances?.every((i) => i.browser === "chromium"));
7970
+ const playwrightChromiumOnly = isPlaywrightChromiumOnly(resolved);
7970
7971
  if (browser.enabled && !playwrightChromiumOnly) {
7971
7972
  const browserConfig = {
7972
7973
  browser: {
@@ -8467,5 +8468,28 @@ function resolveCoverageReporters(configReporters) {
8467
8468
  }
8468
8469
  return resolvedReporters;
8469
8470
  }
8471
+ function isPlaywrightChromiumOnly(config) {
8472
+ const browser = config.browser;
8473
+ if (!browser || browser.provider !== "playwright" || !browser.enabled) {
8474
+ return false;
8475
+ }
8476
+ if (browser.name) {
8477
+ return browser.name === "chromium";
8478
+ }
8479
+ if (!browser.instances) {
8480
+ return false;
8481
+ }
8482
+ const filteredProjects = toArray(config.project).map((p) => wildcardPatternToRegExp(p));
8483
+ for (const instance of browser.instances) {
8484
+ const name = instance.name || (config.name ? `${config.name} (${instance.browser})` : instance.browser);
8485
+ if (filteredProjects.length && !filteredProjects.every((p) => p.test(name))) {
8486
+ continue;
8487
+ }
8488
+ if (instance.browser !== "chromium") {
8489
+ return false;
8490
+ }
8491
+ }
8492
+ return true;
8493
+ }
8470
8494
 
8471
8495
  export { BaseSequencer as B, RandomSequencer as R, VitestCache as V, resolveConfig as a, resolveApiServerConfig as b, coverageConfigDefaults as c, createMethodsRPC as d, requireMicromatch as e, configDefaults as f, getFilePoolName as g, hash as h, isPackageExists as i, isBrowserEnabled as j, groupBy as k, createPool as l, mm as m, resolveCoverageReporters as r, stdout as s, wildcardPatternToRegExp as w };
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCLI } from './chunks/cac.CHB7MTUk.js';
1
+ import { c as createCLI } from './chunks/cac.Cfe6a4o8.js';
2
2
  import '@vitest/utils';
3
3
  import 'events';
4
4
  import 'pathe';
package/dist/coverage.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { existsSync, promises, readdirSync, writeFileSync } from 'node:fs';
2
- import { c as coverageConfigDefaults, r as resolveCoverageReporters, m as mm } from './chunks/resolveConfig.DATSOo7x.js';
2
+ import { c as coverageConfigDefaults, r as resolveCoverageReporters, m as mm } from './chunks/resolveConfig.9CnFfuqj.js';
3
3
  import { resolve, relative } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
5
  import '@vitest/utils';
package/dist/node.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { resolveConfig as resolveConfig$1, mergeConfig, createServer as createServer$1 } from 'vite';
2
2
  export { esbuildVersion, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
3
- import { V as Vitest, a as VitestPlugin, T as TestModule } from './chunks/cli-api.B7hOUwun.js';
4
- export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.B7hOUwun.js';
5
- export { p as parseCLI } from './chunks/cac.CHB7MTUk.js';
6
- import { a as resolveConfig$2 } from './chunks/resolveConfig.DATSOo7x.js';
7
- export { B as BaseSequencer, d as createMethodsRPC, g as getFilePoolName, b as resolveApiServerConfig } from './chunks/resolveConfig.DATSOo7x.js';
3
+ import { V as Vitest, a as VitestPlugin, T as TestModule } from './chunks/cli-api.BaY17YBo.js';
4
+ export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.BaY17YBo.js';
5
+ export { p as parseCLI } from './chunks/cac.Cfe6a4o8.js';
6
+ import { a as resolveConfig$2 } from './chunks/resolveConfig.9CnFfuqj.js';
7
+ export { B as BaseSequencer, d as createMethodsRPC, g as getFilePoolName, b as resolveApiServerConfig } from './chunks/resolveConfig.9CnFfuqj.js';
8
8
  import { slash } from '@vitest/utils';
9
9
  import { f as findUp } from './chunks/index.Bh7wTRhh.js';
10
10
  import { resolve } from 'pathe';
@@ -19,7 +19,7 @@ import '@vitest/snapshot/manager';
19
19
  import 'vite-node/client';
20
20
  import 'vite-node/server';
21
21
  import './chunks/index.TH3f4LSA.js';
22
- import './chunks/index.DyQPL4DO.js';
22
+ import './chunks/index.CvtAP0DU.js';
23
23
  import 'tinyrainbow';
24
24
  import './chunks/utils.DJWL04yX.js';
25
25
  import 'node:util';
package/dist/reporters.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BasicReporter, a as BenchmarkReporter, b as BenchmarkReportsMap, D as DefaultReporter, c as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, d as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, e as TapReporter, V as VerboseBenchmarkReporter, f as VerboseReporter } from './chunks/index.DyQPL4DO.js';
1
+ export { B as BasicReporter, a as BenchmarkReporter, b as BenchmarkReportsMap, D as DefaultReporter, c as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, d as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, e as TapReporter, V as VerboseBenchmarkReporter, f as VerboseReporter } from './chunks/index.CvtAP0DU.js';
2
2
  import 'node:fs';
3
3
  import '@vitest/runner/utils';
4
4
  import 'pathe';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "3.0.2",
4
+ "version": "3.0.3",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -122,8 +122,8 @@
122
122
  "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
123
123
  "happy-dom": "*",
124
124
  "jsdom": "*",
125
- "@vitest/browser": "3.0.2",
126
- "@vitest/ui": "3.0.2"
125
+ "@vitest/browser": "3.0.3",
126
+ "@vitest/ui": "3.0.3"
127
127
  },
128
128
  "peerDependenciesMeta": {
129
129
  "@edge-runtime/vm": {
@@ -158,14 +158,14 @@
158
158
  "tinyrainbow": "^2.0.0",
159
159
  "vite": "^5.0.0 || ^6.0.0",
160
160
  "why-is-node-running": "^2.3.0",
161
- "@vitest/expect": "3.0.2",
162
- "@vitest/mocker": "3.0.2",
163
- "@vitest/runner": "3.0.2",
164
- "@vitest/pretty-format": "^3.0.2",
165
- "@vitest/snapshot": "3.0.2",
166
- "@vitest/spy": "3.0.2",
167
- "vite-node": "3.0.2",
168
- "@vitest/utils": "3.0.2"
161
+ "@vitest/mocker": "3.0.3",
162
+ "@vitest/expect": "3.0.3",
163
+ "@vitest/pretty-format": "^3.0.3",
164
+ "@vitest/runner": "3.0.3",
165
+ "@vitest/snapshot": "3.0.3",
166
+ "@vitest/spy": "3.0.3",
167
+ "@vitest/utils": "3.0.3",
168
+ "vite-node": "3.0.3"
169
169
  },
170
170
  "devDependencies": {
171
171
  "@ampproject/remapping": "^2.3.0",