vitest 0.12.1 → 0.12.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.
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-utils.ebc9e052.js';
2
+ import { c as createBirpc } from './chunk-vite-node-utils.1536f168.js';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -9,11 +9,11 @@ import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import url from 'url';
12
- import { A as API_PATH } from './chunk-constants.07c1f709.js';
13
- import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.d1b169ca.js';
12
+ import { A as API_PATH } from './chunk-constants.0567483c.js';
13
+ import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.f25e8f44.js';
14
14
  import 'module';
15
15
  import 'vm';
16
- import './chunk-utils-global.7092f9ed.js';
16
+ import './chunk-utils-global.a5a8641f.js';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'path';
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { h as resolve } from './chunk-utils-global.7092f9ed.js';
2
+ import { h as resolve } from './chunk-utils-global.a5a8641f.js';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
5
  const defaultPort = 51204;
@@ -1,7 +1,7 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { createRequire } from 'module';
3
3
  import { pathToFileURL } from 'url';
4
- import { t as toArray, h as resolve } from './chunk-utils-global.7092f9ed.js';
4
+ import { t as toArray, h as resolve } from './chunk-utils-global.a5a8641f.js';
5
5
 
6
6
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
7
7
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
@@ -2,7 +2,7 @@ import path$2 from 'path';
2
2
  import fs$2 from 'fs';
3
3
  import require$$0 from 'util';
4
4
  import childProcess$1 from 'child_process';
5
- import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1, o as onetime$1 } from './vendor-index.6c69a0a8.js';
5
+ import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1, o as onetime$1 } from './vendor-index.40be925a.js';
6
6
  import require$$0$1 from 'os';
7
7
  import './vendor-_commonjsHelpers.addc3445.js';
8
8
  import 'assert';
@@ -1,22 +1,22 @@
1
- import { g as globalApis } from './chunk-constants.07c1f709.js';
2
- import { i as index } from './vendor-entry.3062f869.js';
1
+ import { g as globalApis } from './chunk-constants.0567483c.js';
2
+ import { i as index } from './vendor-entry.d50b0f20.js';
3
3
  import 'url';
4
- import './chunk-utils-global.7092f9ed.js';
4
+ import './chunk-utils-global.a5a8641f.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
8
  import 'fs';
9
9
  import 'console';
10
10
  import 'stream';
11
- import './chunk-runtime-chain.da3a4a85.js';
11
+ import './chunk-runtime-chain.f8567c17.js';
12
12
  import 'chai';
13
13
  import './vendor-_commonjsHelpers.addc3445.js';
14
- import './chunk-runtime-rpc.5148195e.js';
15
- import './chunk-utils-timers.d1b169ca.js';
14
+ import './chunk-runtime-rpc.63398738.js';
15
+ import './chunk-utils-timers.f25e8f44.js';
16
16
  import './chunk-integrations-spy.bee66426.js';
17
17
  import 'tinyspy';
18
18
  import 'util';
19
- import './chunk-defaults.9b4b1577.js';
19
+ import './chunk-defaults.ecb46baf.js';
20
20
  import 'module';
21
21
  import 'crypto';
22
22
 
@@ -1,9 +1,9 @@
1
1
  import chai$1, { expect as expect$1, util } from 'chai';
2
2
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
3
- import { r as rpc } from './chunk-runtime-rpc.5148195e.js';
4
- import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, a as getWorkerState, b as getNames, c as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.7092f9ed.js';
3
+ import { r as rpc } from './chunk-runtime-rpc.63398738.js';
4
+ import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, a as getWorkerState, b as getNames, c as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.a5a8641f.js';
5
5
  import fs, { promises } from 'fs';
6
- import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.d1b169ca.js';
6
+ import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.f25e8f44.js';
7
7
  import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.bee66426.js';
8
8
  import require$$0, { format } from 'util';
9
9
 
@@ -624,8 +624,11 @@ function prepareSnapString(snap, source, index) {
624
624
  const lines = snap.trim().replace(/\\/g, "\\\\").replace(/\$/g, "\\$").split(/\n/g);
625
625
  const isOneline = lines.length <= 1;
626
626
  const quote = isOneline ? "'" : "`";
627
- return isOneline ? `'${lines.join("\n").replace(/'/g, "\\'")}'` : `${quote}
628
- ${lines.map((i) => indentNext + i).join("\n").replace(/`/g, "\\`")}
627
+ if (isOneline)
628
+ return `'${lines.join("\n").replace(/'/g, "\\'")}'`;
629
+ else
630
+ return `${quote}
631
+ ${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`")}
629
632
  ${indent}${quote}`;
630
633
  }
631
634
  const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*[\w_$]*(['"`\)])/m;
@@ -1,8 +1,8 @@
1
- import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.ebc9e052.js';
1
+ import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.1536f168.js';
2
2
  import { normalizePath } from 'vite';
3
- import { a as getWorkerState, C as isWindows, D as mergeSlashes, d as dirname, f as basename, h as resolve, E as getType, F as getAllProperties, s as slash } from './chunk-utils-global.7092f9ed.js';
3
+ import { a as getWorkerState, C as isWindows, D as mergeSlashes, d as dirname, f as basename, h as resolve, E as getType, F as getAllProperties, s as slash } from './chunk-utils-global.a5a8641f.js';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { d as distDir } from './chunk-constants.07c1f709.js';
5
+ import { d as distDir } from './chunk-constants.0567483c.js';
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -1,4 +1,4 @@
1
- import { a as getWorkerState } from './chunk-utils-global.7092f9ed.js';
1
+ import { a as getWorkerState } from './chunk-utils-global.a5a8641f.js';
2
2
 
3
3
  const rpc = () => {
4
4
  return getWorkerState().rpc;
@@ -419,7 +419,7 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
419
419
  message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
420
420
  });
421
421
  if (install) {
422
- await (await import('./chunk-install-pkg.fd8d1022.js')).installPackage(dependency, { dev: true });
422
+ await (await import('./chunk-install-pkg.73b84ae1.js')).installPackage(dependency, { dev: true });
423
423
  process.stderr.write(picocolors.exports.yellow(`
424
424
  Package ${dependency} installed, re-run the command to start.
425
425
  `));
@@ -1,4 +1,4 @@
1
- import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.7092f9ed.js';
1
+ import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.a5a8641f.js';
2
2
 
3
3
  const setTimeout$1 = globalThis.setTimeout;
4
4
  const setInterval = globalThis.setInterval;
@@ -2,28 +2,28 @@ import { Buffer } from 'buffer';
2
2
  import path$a from 'path';
3
3
  import childProcess from 'child_process';
4
4
  import process$1 from 'process';
5
- import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.6c69a0a8.js';
5
+ import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.40be925a.js';
6
6
  import url, { fileURLToPath, pathToFileURL } from 'url';
7
7
  import require$$0, { constants as constants$5, cpus, hostname } from 'os';
8
- import { j as join, f as basename, d as dirname, h as resolve, p as picocolors, s as slash$2, k as isAbsolute, l as relative, m as getTests, o as getFullName, q as hasFailed, u as hasFailedSnapshot, v as getSuites, t as toArray, w as normalize, n as noop$1, x as deepMerge, y as toNamespacedPath, g as getCallLastIndex, e as notNullish, z as ensurePackageInstalled, A as stdout } from './chunk-utils-global.7092f9ed.js';
8
+ import { j as join, f as basename, d as dirname, h as resolve, p as picocolors, s as slash$2, k as isAbsolute, l as relative, m as getTests, o as getFullName, q as hasFailed, u as hasFailedSnapshot, v as getSuites, t as toArray, w as normalize, n as noop$1, x as deepMerge, y as toNamespacedPath, g as getCallLastIndex, e as notNullish, z as ensurePackageInstalled, A as stdout } from './chunk-utils-global.a5a8641f.js';
9
9
  import { createServer, mergeConfig } from 'vite';
10
10
  import fs$8, { promises, existsSync, readFileSync } from 'fs';
11
- import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.07c1f709.js';
11
+ import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.0567483c.js';
12
12
  import readline from 'readline';
13
13
  import require$$0$1 from 'util';
14
14
  import require$$0$2 from 'stream';
15
15
  import require$$2 from 'events';
16
16
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
17
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.ebc9e052.js';
18
- import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.9b4b1577.js';
17
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.1536f168.js';
18
+ import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.ecb46baf.js';
19
19
  import { MessageChannel } from 'worker_threads';
20
20
  import { Tinypool } from 'tinypool';
21
21
  import { performance } from 'perf_hooks';
22
- import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.d1b169ca.js';
22
+ import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.f25e8f44.js';
23
23
  import MagicString from './chunk-magic-string.d5e0e473.js';
24
24
  import { p as prompts } from './vendor-index.405e58ef.js';
25
25
 
26
- var version = "0.12.1";
26
+ var version = "0.12.4";
27
27
 
28
28
  function stripFinalNewline(input) {
29
29
  const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
@@ -8012,8 +8012,8 @@ function patchWindowsImportPath(path) {
8012
8012
  }
8013
8013
 
8014
8014
  var __defProp$5 = Object.defineProperty;
8015
- var __defProps$4 = Object.defineProperties;
8016
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
8015
+ var __defProps$5 = Object.defineProperties;
8016
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
8017
8017
  var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8018
8018
  var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8019
8019
  var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
@@ -8029,7 +8029,7 @@ var __spreadValues$5 = (a, b) => {
8029
8029
  }
8030
8030
  return a;
8031
8031
  };
8032
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
8032
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
8033
8033
  const RealDate = Date;
8034
8034
  class ViteNodeServer {
8035
8035
  constructor(server, options = {}) {
@@ -8050,7 +8050,7 @@ class ViteNodeServer {
8050
8050
  async fetchModule(id) {
8051
8051
  if (!this.fetchPromiseMap.has(id)) {
8052
8052
  this.fetchPromiseMap.set(id, this._fetchModule(id).then((r) => {
8053
- return this.options.sourcemap !== true ? __spreadProps$4(__spreadValues$5({}, r), { map: void 0 }) : r;
8053
+ return this.options.sourcemap !== true ? __spreadProps$5(__spreadValues$5({}, r), { map: void 0 }) : r;
8054
8054
  }).finally(() => {
8055
8055
  this.fetchPromiseMap.delete(id);
8056
8056
  }));
@@ -8189,7 +8189,7 @@ function createFakePool(ctx) {
8189
8189
  const { workerPort, port } = createChannel(ctx);
8190
8190
  const data = {
8191
8191
  port: workerPort,
8192
- config: ctx.getConfig(),
8192
+ config: ctx.getSerializableConfig(),
8193
8193
  files,
8194
8194
  invalidates,
8195
8195
  id: 1
@@ -8209,7 +8209,7 @@ function createWorkerPool(ctx) {
8209
8209
  const threadsCount = ctx.config.watch ? Math.max(cpus().length / 2, 1) : Math.max(cpus().length - 1, 1);
8210
8210
  const options = {
8211
8211
  filename: workerPath,
8212
- useAtomics: typeof process.versions.webcontainer !== "string",
8212
+ useAtomics: false,
8213
8213
  maxThreads: ctx.config.maxThreads ?? threadsCount,
8214
8214
  minThreads: ctx.config.minThreads ?? threadsCount
8215
8215
  };
@@ -8221,11 +8221,12 @@ function createWorkerPool(ctx) {
8221
8221
  const runWithFiles = (name) => {
8222
8222
  return async (files, invalidates) => {
8223
8223
  let id = 0;
8224
+ const config = ctx.getSerializableConfig();
8224
8225
  await Promise.all(files.map(async (file) => {
8225
8226
  const { workerPort, port } = createChannel(ctx);
8226
8227
  const data = {
8227
8228
  port: workerPort,
8228
- config: ctx.getConfig(),
8229
+ config,
8229
8230
  files: [file],
8230
8231
  invalidates,
8231
8232
  id: ++id
@@ -8553,13 +8554,22 @@ ${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.blue(" R
8553
8554
  this.start = performance.now();
8554
8555
  }
8555
8556
  onUserConsoleLog(log) {
8556
- if (this.ctx.config.silent)
8557
+ if (!this.shouldLog(log))
8557
8558
  return;
8558
8559
  const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
8559
8560
  this.ctx.log(picocolors.exports.gray(log.type + picocolors.exports.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
8560
8561
  process[log.type].write(`${log.content}
8561
8562
  `);
8562
8563
  }
8564
+ shouldLog(log) {
8565
+ var _a, _b;
8566
+ if (this.ctx.config.silent)
8567
+ return false;
8568
+ const shouldIgnore = (_b = (_a = this.ctx.config).onConsoleLog) == null ? void 0 : _b.call(_a, log.content, log.type);
8569
+ if (shouldIgnore === false)
8570
+ return shouldIgnore;
8571
+ return true;
8572
+ }
8563
8573
  onServerRestart() {
8564
8574
  this.ctx.log(picocolors.exports.cyan("Restarted due to config changes..."));
8565
8575
  }
@@ -9278,6 +9288,8 @@ class DefaultReporter extends BaseReporter {
9278
9288
  }
9279
9289
  onUserConsoleLog(log) {
9280
9290
  var _a;
9291
+ if (!this.shouldLog(log))
9292
+ return;
9281
9293
  (_a = this.renderer) == null ? void 0 : _a.clear();
9282
9294
  super.onUserConsoleLog(log);
9283
9295
  }
@@ -9619,8 +9631,8 @@ class TapReporter {
9619
9631
  }
9620
9632
 
9621
9633
  var __defProp$4 = Object.defineProperty;
9622
- var __defProps$3 = Object.defineProperties;
9623
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
9634
+ var __defProps$4 = Object.defineProperties;
9635
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
9624
9636
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
9625
9637
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
9626
9638
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
@@ -9636,13 +9648,13 @@ var __spreadValues$4 = (a, b) => {
9636
9648
  }
9637
9649
  return a;
9638
9650
  };
9639
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
9651
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
9640
9652
  function flattenTasks$1(task, baseName = "") {
9641
9653
  const base = baseName ? `${baseName} > ` : "";
9642
9654
  if (task.type === "suite") {
9643
9655
  return task.tasks.flatMap((child) => flattenTasks$1(child, `${base}${task.name}`));
9644
9656
  } else {
9645
- return [__spreadProps$3(__spreadValues$4({}, task), {
9657
+ return [__spreadProps$4(__spreadValues$4({}, task), {
9646
9658
  name: `${base}${task.name}`
9647
9659
  })];
9648
9660
  }
@@ -9760,7 +9772,7 @@ class JUnitReporter {
9760
9772
  failures: 0,
9761
9773
  skipped: 0
9762
9774
  });
9763
- return __spreadProps$3(__spreadValues$4({}, file), {
9775
+ return __spreadProps$4(__spreadValues$4({}, file), {
9764
9776
  tasks,
9765
9777
  stats
9766
9778
  });
@@ -9787,8 +9799,8 @@ class JUnitReporter {
9787
9799
  }
9788
9800
 
9789
9801
  var __defProp$3 = Object.defineProperty;
9790
- var __defProps$2 = Object.defineProperties;
9791
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
9802
+ var __defProps$3 = Object.defineProperties;
9803
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
9792
9804
  var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
9793
9805
  var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
9794
9806
  var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
@@ -9804,13 +9816,13 @@ var __spreadValues$3 = (a, b) => {
9804
9816
  }
9805
9817
  return a;
9806
9818
  };
9807
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
9819
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
9808
9820
  function flattenTasks(task, baseName = "") {
9809
9821
  const base = baseName ? `${baseName} > ` : "";
9810
9822
  if (task.type === "suite" && task.tasks.length > 0) {
9811
9823
  return task.tasks.flatMap((child) => flattenTasks(child, `${base}${task.name}`));
9812
9824
  } else {
9813
- return [__spreadProps$2(__spreadValues$3({}, task), {
9825
+ return [__spreadProps$3(__spreadValues$3({}, task), {
9814
9826
  name: `${base}${task.name}`
9815
9827
  })];
9816
9828
  }
@@ -9927,8 +9939,8 @@ class StateManager {
9927
9939
  }
9928
9940
 
9929
9941
  var __defProp$2 = Object.defineProperty;
9930
- var __defProps$1 = Object.defineProperties;
9931
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
9942
+ var __defProps$2 = Object.defineProperties;
9943
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
9932
9944
  var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
9933
9945
  var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
9934
9946
  var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
@@ -9944,7 +9956,7 @@ var __spreadValues$2 = (a, b) => {
9944
9956
  }
9945
9957
  return a;
9946
9958
  };
9947
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
9959
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
9948
9960
  const extraInlineDeps = [
9949
9961
  /^(?!.*(?:node_modules)).*\.mjs$/,
9950
9962
  /^(?!.*(?:node_modules)).*\.cjs\.js$/,
@@ -9987,7 +9999,7 @@ function resolveConfig(options, viteConfig) {
9987
9999
  }
9988
10000
  options.environment = "happy-dom";
9989
10001
  }
9990
- const resolved = __spreadProps$1(__spreadValues$2(__spreadValues$2({}, configDefaults), options), {
10002
+ const resolved = __spreadProps$2(__spreadValues$2(__spreadValues$2({}, configDefaults), options), {
9991
10003
  root: viteConfig.root
9992
10004
  });
9993
10005
  if (viteConfig.base !== "/")
@@ -10246,6 +10258,8 @@ class VitestGit {
10246
10258
  }
10247
10259
 
10248
10260
  var __defProp$1 = Object.defineProperty;
10261
+ var __defProps$1 = Object.defineProperties;
10262
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
10249
10263
  var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
10250
10264
  var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
10251
10265
  var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
@@ -10261,6 +10275,7 @@ var __spreadValues$1 = (a, b) => {
10261
10275
  }
10262
10276
  return a;
10263
10277
  };
10278
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
10264
10279
  const WATCHER_DEBOUNCE = 100;
10265
10280
  const CLOSE_TIMEOUT = 1e3;
10266
10281
  class Vitest {
@@ -10314,18 +10329,14 @@ class Vitest {
10314
10329
  if (resolved.coverage.enabled)
10315
10330
  await cleanCoverage(resolved.coverage, resolved.coverage.clean);
10316
10331
  }
10317
- getConfig() {
10318
- const hasCustomReporter = toArray(this.config.reporters).some((reporter) => typeof reporter !== "string");
10319
- if (this.config.snapshotOptions.resolveSnapshotPath)
10320
- this.config.snapshotOptions.resolveSnapshotPath = void 0;
10321
- if (!hasCustomReporter && !this.configOverride)
10322
- return this.config;
10323
- const config = deepMerge({}, this.config);
10324
- if (this.configOverride)
10325
- deepMerge(config, this.configOverride);
10326
- if (hasCustomReporter)
10327
- config.reporters = [];
10328
- return config;
10332
+ getSerializableConfig() {
10333
+ return deepMerge(__spreadProps$1(__spreadValues$1({}, this.config), {
10334
+ reporters: [],
10335
+ snapshotOptions: __spreadProps$1(__spreadValues$1({}, this.config.snapshotOptions), {
10336
+ resolveSnapshotPath: void 0
10337
+ }),
10338
+ onConsoleLog: void 0
10339
+ }), this.configOverride || {});
10329
10340
  }
10330
10341
  async start(filters) {
10331
10342
  await this.report("onInit", this);
@@ -10429,7 +10440,7 @@ class Vitest {
10429
10440
  this.config.testNamePattern = pattern ? new RegExp(pattern) : void 0;
10430
10441
  await this.rerunFiles(files, trigger);
10431
10442
  }
10432
- async returnFailed() {
10443
+ async rerunFailed() {
10433
10444
  await this.rerunFiles(this.state.getFailedFilepaths(), "rerun failed");
10434
10445
  }
10435
10446
  async updateSnapshot(files) {
@@ -10936,7 +10947,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10936
10947
  await ctx.setServer(options, server);
10937
10948
  haveStarted = true;
10938
10949
  if (options.api && options.watch)
10939
- (await import('./chunk-api-setup.a6d28d1e.js')).setup(ctx);
10950
+ (await import('./chunk-api-setup.ed61899f.js')).setup(ctx);
10940
10951
  if (!options.watch)
10941
10952
  await server.watcher.close();
10942
10953
  }
@@ -10993,6 +11004,8 @@ function registerConsoleShortcuts(ctx) {
10993
11004
  return ctx.updateSnapshot();
10994
11005
  if (name === "a" || name === "return")
10995
11006
  return ctx.rerunFiles(void 0, "rerun all");
11007
+ if (name === "f")
11008
+ return ctx.rerunFailed();
10996
11009
  if (name === "t")
10997
11010
  return inputNamePattern();
10998
11011
  if (name === "q")
@@ -11046,6 +11059,8 @@ async function startVitest(cliFilters, options, viteOverrides) {
11046
11059
  options.coverage = { enabled: options.coverage };
11047
11060
  const ctx = await createVitest(options, viteOverrides);
11048
11061
  process.env.VITEST_MODE = ctx.config.watch ? "WATCH" : "RUN";
11062
+ if (ctx.config.env)
11063
+ Object.assign(process.env, ctx.config.env);
11049
11064
  if (ctx.config.coverage.enabled) {
11050
11065
  if (!await ensurePackageInstalled("c8")) {
11051
11066
  process.exitCode = 1;
@@ -1,7 +1,7 @@
1
1
  import { builtinModules, createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
3
3
  import vm from 'vm';
4
- import { k as isAbsolute$2, h as resolve, j as join$2, B as extname$2, d as dirname$2 } from './chunk-utils-global.7092f9ed.js';
4
+ import { k as isAbsolute$2, h as resolve, j as join$2, B as extname$2, d as dirname$2 } from './chunk-utils-global.a5a8641f.js';
5
5
  import path from 'path';
6
6
  import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
7
7
  import assert from 'assert';
@@ -9003,7 +9003,7 @@ ${getStack()}`), 2e3);
9003
9003
  exports.default = value;
9004
9004
  },
9005
9005
  get exports() {
9006
- return exports.default;
9006
+ return exports;
9007
9007
  }
9008
9008
  };
9009
9009
  const context = this.prepareContext({
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { EventEmitter } from 'events';
2
- import { p as picocolors } from './chunk-utils-global.7092f9ed.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.dcc18b18.js';
2
+ import { p as picocolors } from './chunk-utils-global.a5a8641f.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.cfbecaaf.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
7
  import 'buffer';
8
8
  import 'child_process';
9
9
  import 'process';
10
- import './vendor-index.6c69a0a8.js';
10
+ import './vendor-index.40be925a.js';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
12
  import 'fs';
13
13
  import 'assert';
@@ -16,16 +16,16 @@ import 'util';
16
16
  import 'url';
17
17
  import 'os';
18
18
  import 'vite';
19
- import './chunk-constants.07c1f709.js';
19
+ import './chunk-constants.0567483c.js';
20
20
  import 'readline';
21
- import './chunk-vite-node-utils.ebc9e052.js';
21
+ import './chunk-vite-node-utils.1536f168.js';
22
22
  import 'module';
23
23
  import 'vm';
24
- import './chunk-defaults.9b4b1577.js';
24
+ import './chunk-defaults.ecb46baf.js';
25
25
  import 'worker_threads';
26
26
  import 'tinypool';
27
27
  import 'perf_hooks';
28
- import './chunk-utils-timers.d1b169ca.js';
28
+ import './chunk-utils-timers.f25e8f44.js';
29
29
  import './chunk-magic-string.d5e0e473.js';
30
30
  import './vendor-index.405e58ef.js';
31
31
 
package/dist/entry.js CHANGED
@@ -1,20 +1,20 @@
1
- export { r as run } from './vendor-entry.3062f869.js';
1
+ export { r as run } from './vendor-entry.d50b0f20.js';
2
2
  import 'fs';
3
- import './chunk-utils-global.7092f9ed.js';
3
+ import './chunk-utils-global.a5a8641f.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
7
  import 'console';
8
8
  import 'stream';
9
- import './chunk-runtime-chain.da3a4a85.js';
9
+ import './chunk-runtime-chain.f8567c17.js';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
- import './chunk-runtime-rpc.5148195e.js';
13
- import './chunk-utils-timers.d1b169ca.js';
12
+ import './chunk-runtime-rpc.63398738.js';
13
+ import './chunk-utils-timers.f25e8f44.js';
14
14
  import './chunk-integrations-spy.bee66426.js';
15
15
  import 'tinyspy';
16
16
  import 'util';
17
- import './chunk-defaults.9b4b1577.js';
17
+ import './chunk-defaults.ecb46baf.js';
18
18
  import 'module';
19
19
  import 'url';
20
20
  import 'crypto';
package/dist/index.d.ts CHANGED
@@ -445,14 +445,14 @@ declare class Vitest {
445
445
  private _onRestartListeners;
446
446
  constructor();
447
447
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
448
- getConfig(): ResolvedConfig;
448
+ getSerializableConfig(): ResolvedConfig;
449
449
  start(filters?: string[]): Promise<void>;
450
450
  private getTestDependencies;
451
451
  filterTestsBySource(tests: string[]): Promise<string[]>;
452
452
  runFiles(files: string[]): Promise<void>;
453
453
  rerunFiles(files?: string[], trigger?: string): Promise<void>;
454
454
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
455
- returnFailed(): Promise<void>;
455
+ rerunFailed(): Promise<void>;
456
456
  updateSnapshot(files?: string[]): Promise<void>;
457
457
  log(...args: any[]): void;
458
458
  error(...args: any[]): void;
@@ -491,6 +491,7 @@ declare abstract class BaseReporter implements Reporter {
491
491
  onWatcherStart(): Promise<void>;
492
492
  onWatcherRerun(files: string[], trigger?: string): Promise<void>;
493
493
  onUserConsoleLog(log: UserConsoleLog): void;
494
+ shouldLog(log: UserConsoleLog): boolean;
494
495
  onServerRestart(): void;
495
496
  reportSummary(files: File[]): Promise<void>;
496
497
  private printTaskErrors;
@@ -1232,10 +1233,20 @@ interface InlineConfig {
1232
1233
  * Show heap usage after each test. Usefull for debugging memory leaks.
1233
1234
  */
1234
1235
  logHeapUsage?: boolean;
1236
+ /**
1237
+ * Custom environment variables assigned to `process.env` before running tests.
1238
+ */
1239
+ env?: Record<string, string>;
1235
1240
  /**
1236
1241
  * Options for @sinon/fake-timers
1237
1242
  */
1238
1243
  fakeTimers?: FakeTimerInstallOpts;
1244
+ /**
1245
+ * Custom handler for console.log in tests.
1246
+ *
1247
+ * Return `false` to ignore the log.
1248
+ */
1249
+ onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
1239
1250
  }
1240
1251
  interface UserConfig extends InlineConfig {
1241
1252
  /**
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.da3a4a85.js';
1
+ export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.f8567c17.js';
2
2
  export { assert, default as chai, should } from 'chai';
3
3
  import './vendor-_commonjsHelpers.addc3445.js';
4
- import './chunk-runtime-rpc.5148195e.js';
5
- import './chunk-utils-global.7092f9ed.js';
4
+ import './chunk-runtime-rpc.63398738.js';
5
+ import './chunk-utils-global.a5a8641f.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
9
9
  import 'fs';
10
- import './chunk-utils-timers.d1b169ca.js';
10
+ import './chunk-utils-timers.f25e8f44.js';
11
11
  import './chunk-integrations-spy.bee66426.js';
12
12
  import 'tinyspy';
13
13
  import 'util';
package/dist/node.d.ts CHANGED
@@ -291,6 +291,7 @@ declare abstract class BaseReporter implements Reporter {
291
291
  onWatcherStart(): Promise<void>;
292
292
  onWatcherRerun(files: string[], trigger?: string): Promise<void>;
293
293
  onUserConsoleLog(log: UserConsoleLog): void;
294
+ shouldLog(log: UserConsoleLog): boolean;
294
295
  onServerRestart(): void;
295
296
  reportSummary(files: File[]): Promise<void>;
296
297
  private printTaskErrors;
@@ -934,10 +935,20 @@ interface InlineConfig {
934
935
  * Show heap usage after each test. Usefull for debugging memory leaks.
935
936
  */
936
937
  logHeapUsage?: boolean;
938
+ /**
939
+ * Custom environment variables assigned to `process.env` before running tests.
940
+ */
941
+ env?: Record<string, string>;
937
942
  /**
938
943
  * Options for @sinon/fake-timers
939
944
  */
940
945
  fakeTimers?: FakeTimerInstallOpts;
946
+ /**
947
+ * Custom handler for console.log in tests.
948
+ *
949
+ * Return `false` to ignore the log.
950
+ */
951
+ onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
941
952
  }
942
953
  interface UserConfig extends InlineConfig {
943
954
  /**
@@ -1044,14 +1055,14 @@ declare class Vitest {
1044
1055
  private _onRestartListeners;
1045
1056
  constructor();
1046
1057
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
1047
- getConfig(): ResolvedConfig;
1058
+ getSerializableConfig(): ResolvedConfig;
1048
1059
  start(filters?: string[]): Promise<void>;
1049
1060
  private getTestDependencies;
1050
1061
  filterTestsBySource(tests: string[]): Promise<string[]>;
1051
1062
  runFiles(files: string[]): Promise<void>;
1052
1063
  rerunFiles(files?: string[], trigger?: string): Promise<void>;
1053
1064
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
1054
- returnFailed(): Promise<void>;
1065
+ rerunFailed(): Promise<void>;
1055
1066
  updateSnapshot(files?: string[]): Promise<void>;
1056
1067
  log(...args: any[]): void;
1057
1068
  error(...args: any[]): void;
package/dist/node.js CHANGED
@@ -1,10 +1,10 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.dcc18b18.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.c6de56c0.js';
1
+ export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.cfbecaaf.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.acd615bd.js';
3
3
  import 'buffer';
4
4
  import 'path';
5
5
  import 'child_process';
6
6
  import 'process';
7
- import './vendor-index.6c69a0a8.js';
7
+ import './vendor-index.40be925a.js';
8
8
  import './vendor-_commonjsHelpers.addc3445.js';
9
9
  import 'fs';
10
10
  import 'assert';
@@ -13,19 +13,19 @@ import 'stream';
13
13
  import 'util';
14
14
  import 'url';
15
15
  import 'os';
16
- import './chunk-utils-global.7092f9ed.js';
16
+ import './chunk-utils-global.a5a8641f.js';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'vite';
20
- import './chunk-constants.07c1f709.js';
20
+ import './chunk-constants.0567483c.js';
21
21
  import 'readline';
22
- import './chunk-vite-node-utils.ebc9e052.js';
22
+ import './chunk-vite-node-utils.1536f168.js';
23
23
  import 'module';
24
24
  import 'vm';
25
- import './chunk-defaults.9b4b1577.js';
25
+ import './chunk-defaults.ecb46baf.js';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
28
28
  import 'perf_hooks';
29
- import './chunk-utils-timers.d1b169ca.js';
29
+ import './chunk-utils-timers.f25e8f44.js';
30
30
  import './chunk-magic-string.d5e0e473.js';
31
31
  import './vendor-index.405e58ef.js';
@@ -1,13 +1,13 @@
1
1
  import { promises } from 'fs';
2
- import { a as getWorkerState, t as toArray, G as clone, E as getType, l as relative, A as stdout, H as partitionSuiteChildren, I as hasTests, q as hasFailed, o as getFullName, r as resetModules } from './chunk-utils-global.7092f9ed.js';
2
+ import { a as getWorkerState, t as toArray, G as clone, E as getType, l as relative, H as partitionSuiteChildren, I as hasTests, q as hasFailed, o as getFullName, r as resetModules } from './chunk-utils-global.a5a8641f.js';
3
3
  import { Console } from 'console';
4
4
  import { Writable } from 'stream';
5
5
  import { importModule } from 'local-pkg';
6
- import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.da3a4a85.js';
6
+ import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.f8567c17.js';
7
7
  import chai, { assert, should, util } from 'chai';
8
- import { r as rpc } from './chunk-runtime-rpc.5148195e.js';
9
- import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.d1b169ca.js';
10
- import { t as takeCoverage } from './chunk-defaults.9b4b1577.js';
8
+ import { r as rpc } from './chunk-runtime-rpc.63398738.js';
9
+ import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.f25e8f44.js';
10
+ import { t as takeCoverage } from './chunk-defaults.ecb46baf.js';
11
11
  import { createHash } from 'crypto';
12
12
  import { format } from 'util';
13
13
 
@@ -495,7 +495,7 @@ async function setupGlobalEnv(config) {
495
495
  globalSetup = true;
496
496
  setupConsoleLogSpy();
497
497
  if (config.globals)
498
- (await import('./chunk-integrations-globals.bc12987e.js')).registerApiGlobally();
498
+ (await import('./chunk-integrations-globals.f3e83abb.js')).registerApiGlobally();
499
499
  }
500
500
  function setupDefines(defines) {
501
501
  for (const key in defines)
@@ -761,7 +761,6 @@ async function collectTests(paths, config) {
761
761
  state: "fail",
762
762
  error: processError(e)
763
763
  };
764
- stdout().write("\0");
765
764
  }
766
765
  calculateHash(file);
767
766
  const hasOnlyTasks = someTasksAreOnly(file);
package/dist/worker.js CHANGED
@@ -1,8 +1,8 @@
1
- import { h as resolve, a as getWorkerState, A as stdout } from './chunk-utils-global.7092f9ed.js';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.ebc9e052.js';
3
- import { d as distDir } from './chunk-constants.07c1f709.js';
4
- import { e as executeInViteNode } from './chunk-runtime-mocker.c6de56c0.js';
5
- import { r as rpc } from './chunk-runtime-rpc.5148195e.js';
1
+ import { h as resolve, a as getWorkerState } from './chunk-utils-global.a5a8641f.js';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.1536f168.js';
3
+ import { d as distDir } from './chunk-constants.0567483c.js';
4
+ import { e as executeInViteNode } from './chunk-runtime-mocker.acd615bd.js';
5
+ import { r as rpc } from './chunk-runtime-rpc.63398738.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
@@ -54,7 +54,6 @@ async function startViteNode(ctx) {
54
54
  function init(ctx) {
55
55
  if (typeof __vitest_worker__ !== "undefined" && ctx.config.threads && ctx.config.isolate)
56
56
  throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
57
- stdout().write("\0");
58
57
  const { config, port, id } = ctx;
59
58
  process.env.VITEST_WORKER_ID = String(id);
60
59
  globalThis.__vitest_worker__ = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.12.1",
4
+ "version": "0.12.4",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "keywords": [
7
7
  "vite",
@@ -81,7 +81,7 @@
81
81
  "local-pkg": "^0.4.1",
82
82
  "tinypool": "^0.1.3",
83
83
  "tinyspy": "^0.3.2",
84
- "vite": "^2.9.7"
84
+ "vite": "^2.9.8"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@antfu/install-pkg": "^0.1.0",
@@ -93,7 +93,7 @@
93
93
  "@types/node": "^17.0.31",
94
94
  "@types/prompts": "^2.4.0",
95
95
  "@types/sinonjs__fake-timers": "^8.1.2",
96
- "@vitest/ui": "0.12.1",
96
+ "@vitest/ui": "0.12.4",
97
97
  "birpc": "^0.2.2",
98
98
  "c8": "^7.11.2",
99
99
  "cac": "^6.7.12",
@@ -120,7 +120,7 @@
120
120
  "source-map-js": "^1.0.2",
121
121
  "strip-ansi": "^7.0.1",
122
122
  "typescript": "^4.6.4",
123
- "vite-node": "0.12.1",
123
+ "vite-node": "0.12.4",
124
124
  "ws": "^8.6.0"
125
125
  },
126
126
  "engines": {