vitest 0.0.115 → 0.0.116

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.
package/LICENSE.md CHANGED
@@ -1205,34 +1205,6 @@ Repository: https://github.com/boblauer/MockDate.git
1205
1205
 
1206
1206
  ---------------------------------------
1207
1207
 
1208
- ## nanoid
1209
- License: MIT
1210
- By: Andrey Sitnik
1211
- Repository: ai/nanoid
1212
-
1213
- > The MIT License (MIT)
1214
- >
1215
- > Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
1216
- >
1217
- > Permission is hereby granted, free of charge, to any person obtaining a copy of
1218
- > this software and associated documentation files (the "Software"), to deal in
1219
- > the Software without restriction, including without limitation the rights to
1220
- > use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1221
- > the Software, and to permit persons to whom the Software is furnished to do so,
1222
- > subject to the following conditions:
1223
- >
1224
- > The above copyright notice and this permission notice shall be included in all
1225
- > copies or substantial portions of the Software.
1226
- >
1227
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1228
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1229
- > FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1230
- > COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1231
- > IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1232
- > CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1233
-
1234
- ---------------------------------------
1235
-
1236
1208
  ## natural-compare
1237
1209
  License: MIT
1238
1210
  By: Lauri Rooden
@@ -1921,6 +1893,33 @@ Repository: chalk/wrap-ansi
1921
1893
 
1922
1894
  ---------------------------------------
1923
1895
 
1896
+ ## ws
1897
+ License: MIT
1898
+ By: Einar Otto Stangvik
1899
+ Repository: websockets/ws
1900
+
1901
+ > Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
1902
+ >
1903
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
1904
+ > of this software and associated documentation files (the "Software"), to deal
1905
+ > in the Software without restriction, including without limitation the rights
1906
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1907
+ > copies of the Software, and to permit persons to whom the Software is
1908
+ > furnished to do so, subject to the following conditions:
1909
+ >
1910
+ > The above copyright notice and this permission notice shall be included in all
1911
+ > copies or substantial portions of the Software.
1912
+ >
1913
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1914
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1915
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1916
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1917
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1918
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
+ > SOFTWARE.
1920
+
1921
+ ---------------------------------------
1922
+
1924
1923
  ## yocto-queue
1925
1924
  License: MIT
1926
1925
  By: Sindre Sorhus
package/dist/cli.js CHANGED
@@ -7,8 +7,8 @@ import process$1 from 'process';
7
7
  import { m as mergeStream, g as getStream, c as crossSpawn } from './index-6e709f57.js';
8
8
  import require$$0, { constants } from 'os';
9
9
  import { s as signalExit } from './index-648e7ab2.js';
10
- import { e as ensurePackageInstalled } from './index-7c024e16.js';
11
- import { c as createVitest } from './index-b4f86684.js';
10
+ import { e as ensurePackageInstalled } from './index-bf29f0e6.js';
11
+ import { c as createVitest } from './index-1af8810e.js';
12
12
  import './_commonjsHelpers-c9e3b764.js';
13
13
  import 'fs';
14
14
  import 'stream';
@@ -18,10 +18,10 @@ import 'url';
18
18
  import 'tty';
19
19
  import 'local-pkg';
20
20
  import 'vite';
21
- import './constants-5968a78c.js';
21
+ import './constants-080f26e8.js';
22
22
  import './magic-string.es-94000aea.js';
23
23
  import 'perf_hooks';
24
- import './diff-67678e1f.js';
24
+ import './diff-80c47cfa.js';
25
25
  import 'module';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
@@ -1700,10 +1700,10 @@ function execa(file, args, options) {
1700
1700
  return mergePromise(spawned, handlePromiseOnce);
1701
1701
  }
1702
1702
 
1703
- var version = "0.0.115";
1703
+ var version = "0.0.116";
1704
1704
 
1705
1705
  const cli = cac("vitest");
1706
- 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", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent console.log output from tests").option("--reporter <name>", "reporter").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", { default: "node" }).option("--passWithNoTests", "pass when no tests found").help();
1706
+ 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", "watch mode").option("-o, --open", "open UI", { default: false }).option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent console output from tests").option("--reporter <name>", "reporter").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", { default: "node" }).option("--passWithNoTests", "pass when no tests found").help();
1707
1707
  cli.command("run [...filters]").action(run);
1708
1708
  cli.command("watch [...filters]").action(dev);
1709
1709
  cli.command("dev [...filters]").action(dev);
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { k as resolve } from './index-7c024e16.js';
2
+ import { k as resolve } from './index-bf29f0e6.js';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
5
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
@@ -1,5 +1,5 @@
1
1
  import { existsSync, promises } from 'fs';
2
- import { o as notNullish, c, r as relative } from './index-7c024e16.js';
2
+ import { o as notNullish, c, r as relative } from './index-bf29f0e6.js';
3
3
 
4
4
  function Diff() {}
5
5
  Diff.prototype = {
package/dist/entry.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import fs, { promises } from 'fs';
2
- import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, n as nanoid, l as clearContext, m as defaultSuite, o as setHooks, p as getHooks, q as context, s as setState, r as getFn, b as getState, e as vi } from './vi-2115c609.js';
2
+ import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-b3412f83.js';
3
3
  import { Console } from 'console';
4
4
  import { Writable } from 'stream';
5
5
  import { importModule } from 'local-pkg';
6
6
  import chai$1, { expect, util } from 'chai';
7
7
  import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
8
- import { q as index, s as slash, u as getNames, c as c$1, t as toArray, r as relative, v as interpretOnlyMode, w as partitionSuiteChildren, x as hasTests, h as hasFailed } from './index-7c024e16.js';
8
+ import { q as index, s as slash, u as getNames, c as c$1, t as toArray, r as relative, v as interpretOnlyMode, w as partitionSuiteChildren, x as hasTests, h as hasFailed } from './index-bf29f0e6.js';
9
9
  import { r as rpc } from './rpc-8c7cc374.js';
10
- import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-67678e1f.js';
10
+ import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-80c47cfa.js';
11
11
  import { performance } from 'perf_hooks';
12
+ import { createHash } from 'crypto';
12
13
  import { format as format$1 } from 'util';
13
14
  import './jest-mock-4a754991.js';
14
15
  import 'tinyspy';
@@ -402,12 +403,13 @@ async function saveInlineSnapshots(snapshots) {
402
403
  }));
403
404
  }
404
405
  const startRegex = /toMatchInlineSnapshot\s*\(\s*(['"`\)])/m;
405
- function replaceInlineSnap(code, s, index, newSnap) {
406
+ function replaceInlineSnap(code, s, index, newSnap, indent = "") {
406
407
  const startMatch = startRegex.exec(code.slice(index));
407
408
  if (!startMatch)
408
409
  return false;
409
- newSnap = newSnap.replace(/\\/g, "\\\\");
410
- const snapString = newSnap.includes("\n") ? `\`${newSnap.replace(/`/g, "\\`").trimEnd()}\`` : `'${newSnap.replace(/'/g, "\\'")}'`;
410
+ newSnap = newSnap.replace(/\\/g, "\\\\").split("\n").map((i) => (indent + i).trimEnd()).join("\n");
411
+ const isOneline = !newSnap.includes("\n");
412
+ const snapString = isOneline ? `'${newSnap.replace(/'/g, "\\'").trim()}'` : `\`${newSnap.replace(/`/g, "\\`").trimEnd()}\``;
411
413
  const quote = startMatch[1];
412
414
  const startIndex = index + startMatch.index + startMatch[0].length;
413
415
  if (quote === ")") {
@@ -3530,7 +3532,7 @@ async function setupGlobalEnv(config) {
3530
3532
  setupConsoleLogSpy();
3531
3533
  await setupChai();
3532
3534
  if (config.global)
3533
- (await import('./global-bc40af7c.js')).registerApiGlobally();
3535
+ (await import('./global-a73dfade.js')).registerApiGlobally();
3534
3536
  }
3535
3537
  function setupConsoleLogSpy() {
3536
3538
  const stdout = new Writable({
@@ -3578,7 +3580,7 @@ async function runSetupFiles(config) {
3578
3580
  }));
3579
3581
  }
3580
3582
 
3581
- function serializeError(val) {
3583
+ function serializeError(val, seen = /* @__PURE__ */ new WeakSet()) {
3582
3584
  if (!val || typeof val === "string")
3583
3585
  return val;
3584
3586
  if (typeof val === "function")
@@ -3591,8 +3593,11 @@ function serializeError(val) {
3591
3593
  return val.tagName;
3592
3594
  if (typeof val.asymmetricMatch === "function")
3593
3595
  return `${val.toString()} ${format$1(val.sample)}`;
3596
+ if (seen.has(val))
3597
+ return val;
3598
+ seen.add(val);
3594
3599
  Object.keys(val).forEach((key) => {
3595
- val[key] = serializeError(val[key]);
3600
+ val[key] = serializeError(val[key], seen);
3596
3601
  });
3597
3602
  return val;
3598
3603
  }
@@ -3610,12 +3615,16 @@ function processError(err) {
3610
3615
  return serializeError(err);
3611
3616
  }
3612
3617
 
3618
+ function hash(str, length = 10) {
3619
+ return createHash("md5").update(str).digest("hex").slice(0, length);
3620
+ }
3613
3621
  async function collectTests(paths, config) {
3614
3622
  const files = [];
3615
3623
  for (const filepath of paths) {
3624
+ const path = relative(config.root, filepath);
3616
3625
  const file = {
3617
- id: nanoid(),
3618
- name: relative(config.root, filepath),
3626
+ id: hash(path),
3627
+ name: path,
3619
3628
  type: "suite",
3620
3629
  mode: "run",
3621
3630
  computeMode: "serial",
@@ -3647,12 +3656,20 @@ async function collectTests(paths, config) {
3647
3656
  };
3648
3657
  process.stdout.write("\0");
3649
3658
  }
3659
+ calculateHash(file);
3650
3660
  files.push(file);
3651
3661
  }
3652
3662
  const tasks = files.reduce((tasks2, file) => tasks2.concat(file.tasks), []);
3653
3663
  interpretOnlyMode(tasks);
3654
3664
  return files;
3655
3665
  }
3666
+ function calculateHash(parent) {
3667
+ parent.tasks.forEach((t, idx) => {
3668
+ t.id = `${parent.id}_${idx}`;
3669
+ if (t.type === "suite")
3670
+ calculateHash(t);
3671
+ });
3672
+ }
3656
3673
 
3657
3674
  async function callSuiteHook(suite, name, args) {
3658
3675
  if (name === "beforeEach" && suite.suite)
@@ -3661,8 +3678,24 @@ async function callSuiteHook(suite, name, args) {
3661
3678
  if (name === "afterEach" && suite.suite)
3662
3679
  await callSuiteHook(suite.suite, name, args);
3663
3680
  }
3681
+ const packs = [];
3682
+ let updateTimer;
3683
+ let previousUpdate;
3664
3684
  function updateTask(task) {
3665
- return rpc().onTaskUpdate([task.id, task.result]);
3685
+ packs.push([task.id, task.result]);
3686
+ clearTimeout(updateTimer);
3687
+ updateTimer = setTimeout(() => {
3688
+ previousUpdate = sendTasksUpdate();
3689
+ }, 10);
3690
+ }
3691
+ async function sendTasksUpdate() {
3692
+ clearTimeout(updateTimer);
3693
+ await previousUpdate;
3694
+ if (packs.length) {
3695
+ const p = rpc().onTaskUpdate(packs);
3696
+ packs.length = 0;
3697
+ return p;
3698
+ }
3666
3699
  }
3667
3700
  async function runTest(test) {
3668
3701
  if (test.mode !== "run")
@@ -3764,6 +3797,7 @@ async function startTests(paths, config) {
3764
3797
  rpc().onCollected(files);
3765
3798
  await runSuites(files);
3766
3799
  await getSnapshotClient().saveSnap();
3800
+ await sendTasksUpdate();
3767
3801
  }
3768
3802
  function clearModuleMocks() {
3769
3803
  const { clearMocks, mockReset, restoreMocks } = process.__vitest_worker__.config;
@@ -1,11 +1,11 @@
1
- import { g as globalApis } from './constants-5968a78c.js';
2
- import { i as index } from './index-7f57c252.js';
1
+ import { g as globalApis } from './constants-080f26e8.js';
2
+ import { i as index } from './index-80d9a771.js';
3
3
  import 'url';
4
- import './index-7c024e16.js';
4
+ import './index-bf29f0e6.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
- import './vi-2115c609.js';
8
+ import './vi-b3412f83.js';
9
9
  import './_commonjsHelpers-c9e3b764.js';
10
10
  import './jest-mock-4a754991.js';
11
11
  import 'chai';
@@ -1,4 +1,4 @@
1
- import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-7c024e16.js';
1
+ import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-bf29f0e6.js';
2
2
  import { createServer, mergeConfig } from 'vite';
3
3
  import path$a from 'path';
4
4
  import process$1 from 'process';
@@ -7,10 +7,10 @@ import require$$0 from 'os';
7
7
  import require$$0$1 from 'util';
8
8
  import require$$0$2 from 'stream';
9
9
  import require$$2 from 'events';
10
- import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-5968a78c.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-080f26e8.js';
11
11
  import MagicString from './magic-string.es-94000aea.js';
12
12
  import { performance } from 'perf_hooks';
13
- import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-67678e1f.js';
13
+ import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-80c47cfa.js';
14
14
  import { o as onetime, s as signalExit } from './index-648e7ab2.js';
15
15
  import { createRequire } from 'module';
16
16
  import { pathToFileURL } from 'url';
@@ -6988,15 +6988,17 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
6988
6988
  this.end = performance.now();
6989
6989
  await this.reportSummary(files);
6990
6990
  }
6991
- onTaskUpdate(pack) {
6991
+ onTaskUpdate(packs) {
6992
6992
  var _a, _b, _c;
6993
6993
  if (this.isTTY)
6994
6994
  return;
6995
- const task = this.ctx.state.idMap[pack[0]];
6996
- if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
6997
- this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
6998
- if (task.result.state === "fail")
6999
- this.ctx.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
6995
+ for (const pack of packs) {
6996
+ const task = this.ctx.state.idMap[pack[0]];
6997
+ if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
6998
+ this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
6999
+ if (task.result.state === "fail")
7000
+ this.ctx.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
7001
+ }
7000
7002
  }
7001
7003
  }
7002
7004
  async onWatcherStart() {
@@ -7015,8 +7017,9 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
7015
7017
  async onWatcherRerun(files, trigger) {
7016
7018
  this.watchFilters = files;
7017
7019
  this.ctx.console.clear();
7018
- this.ctx.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
7019
- `));
7020
+ this.ctx.log(c.blue("Re-running tests...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
7021
+ `) : ""));
7022
+ this.start = performance.now();
7020
7023
  }
7021
7024
  onUserConsoleLog(log) {
7022
7025
  if (this.ctx.config.silent)
@@ -7683,7 +7686,7 @@ class DefaultReporter extends BaseReporter {
7683
7686
  super(...arguments);
7684
7687
  this.rendererOptions = {};
7685
7688
  }
7686
- onStart() {
7689
+ onCollected() {
7687
7690
  if (this.isTTY) {
7688
7691
  this.rendererOptions.outputStream = this.ctx.outputStream;
7689
7692
  const files = this.ctx.state.getFiles(this.watchFilters);
@@ -7775,7 +7778,7 @@ const createDotRenderer = (_tasks, options) => {
7775
7778
  };
7776
7779
 
7777
7780
  class DotReporter extends BaseReporter {
7778
- onStart() {
7781
+ onCollected() {
7779
7782
  if (this.isTTY) {
7780
7783
  const files = this.ctx.state.getFiles(this.watchFilters);
7781
7784
  if (!this.renderer)
@@ -7908,7 +7911,7 @@ class StateManager {
7908
7911
  return keys.map((key) => this.filesMap[key]);
7909
7912
  return Object.values(this.filesMap);
7910
7913
  }
7911
- collectFiles(files) {
7914
+ collectFiles(files = []) {
7912
7915
  files.forEach((file) => {
7913
7916
  this.filesMap[file.filepath] = file;
7914
7917
  this.updateId(file);
@@ -8120,11 +8123,11 @@ function createChannel(ctx) {
8120
8123
  },
8121
8124
  onCollected(files) {
8122
8125
  ctx.state.collectFiles(files);
8123
- ctx.report("onStart", files.map((i) => i.filepath));
8126
+ ctx.report("onCollected", files);
8124
8127
  },
8125
- onTaskUpdate(pack) {
8126
- ctx.state.updateTasks([pack]);
8127
- ctx.report("onTaskUpdate", pack);
8128
+ onTaskUpdate(packs) {
8129
+ ctx.state.updateTasks(packs);
8130
+ ctx.report("onTaskUpdate", packs);
8128
8131
  },
8129
8132
  onUserLog(msg) {
8130
8133
  ctx.report("onUserConsoleLog", msg);
@@ -8245,7 +8248,7 @@ class Vitest {
8245
8248
  this.snapshot.clear();
8246
8249
  const files = Array.from(this.changedTests);
8247
8250
  this.changedTests.clear();
8248
- this.console.log("return");
8251
+ this.log("return");
8249
8252
  if (this.config.coverage.enabled && this.config.coverage.cleanOnRerun)
8250
8253
  await cleanCoverage(this.config.coverage);
8251
8254
  await this.report("onWatcherRerun", files, triggerId);
@@ -8353,7 +8356,7 @@ async function createVitest(options, viteOverrides = {}) {
8353
8356
  await ctx.setServer(options, server2);
8354
8357
  haveStarted = true;
8355
8358
  if (options.api)
8356
- server2.middlewares.use((await import('./middleware-647438b9.js')).default(ctx));
8359
+ (await import('./setup-95b119ff.js')).setup(ctx);
8357
8360
  }
8358
8361
  },
8359
8362
  MocksPlugin()
@@ -8372,6 +8375,8 @@ async function createVitest(options, viteOverrides = {}) {
8372
8375
  await server.pluginContainer.buildStart({});
8373
8376
  if (options.api === true)
8374
8377
  options.api = defaultPort;
8378
+ if (options.open && !options.api)
8379
+ options.api = defaultPort;
8375
8380
  if (typeof options.api === "number")
8376
8381
  await server.listen(options.api);
8377
8382
  return ctx;
@@ -1,4 +1,4 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-2115c609.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-b3412f83.js';
2
2
  import chai, { assert, should } from 'chai';
3
3
  import { s as spies, a as spyOn, f as fn } from './jest-mock-4a754991.js';
4
4
 
@@ -334,7 +334,8 @@ function getFullName(task) {
334
334
  async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
335
335
  if (isPackageExists(dependency))
336
336
  return true;
337
- console.log(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
337
+ process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
338
+
338
339
  `));
339
340
  if (!promptInstall)
340
341
  return false;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import { Formatter } from 'picocolors/types';
2
2
  import { ViteDevServer } from 'vite';
3
3
  import { RawSourceMap } from 'source-map-js';
4
4
  import { OptionsReceived } from 'pretty-format';
5
- import { Arrayable as Arrayable$1 } from 'vitest';
6
5
  import { MessagePort } from 'worker_threads';
7
6
  export { Spy, SpyFn } from 'tinyspy';
8
7
  export { assert, default as chai, should } from 'chai';
@@ -182,7 +181,7 @@ declare class StateManager {
182
181
  idMap: Record<string, Task>;
183
182
  taskFileMap: WeakMap<Task, File>;
184
183
  getFiles(keys?: string[]): File[];
185
- collectFiles(files: File[]): void;
184
+ collectFiles(files?: File[]): void;
186
185
  updateId(task: Task): void;
187
186
  updateTasks(packs: TaskResultPack[]): void;
188
187
  }
@@ -235,10 +234,10 @@ declare abstract class BaseReporter implements Reporter {
235
234
  onInit(ctx: Vitest): void;
236
235
  relative(path: string): string;
237
236
  onFinished(files?: File[]): Promise<void>;
238
- onTaskUpdate(pack: TaskResultPack): void;
237
+ onTaskUpdate(packs: TaskResultPack[]): void;
239
238
  isFirstWatchRun: boolean;
240
239
  onWatcherStart(): Promise<void>;
241
- onWatcherRerun(files: string[], trigger: string): Promise<void>;
240
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
242
241
  onUserConsoleLog(log: UserConsoleLog): void;
243
242
  onServerRestart(): void;
244
243
  reportSummary(files: File[]): Promise<void>;
@@ -259,21 +258,21 @@ declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions)
259
258
  declare class DefaultReporter extends BaseReporter {
260
259
  renderer?: ReturnType<typeof createListRenderer>;
261
260
  rendererOptions: ListRendererOptions;
262
- onStart(): void;
261
+ onCollected(): void;
263
262
  onFinished(files?: File[]): Promise<void>;
264
263
  onWatcherStart(): Promise<void>;
265
264
  stopListRender(): Promise<void>;
266
- onWatcherRerun(files: string[], trigger: string): Promise<void>;
265
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
267
266
  onUserConsoleLog(log: UserConsoleLog): void;
268
267
  }
269
268
 
270
269
  declare class DotReporter extends BaseReporter {
271
270
  renderer?: ReturnType<typeof createListRenderer>;
272
- onStart(): void;
271
+ onCollected(): void;
273
272
  onFinished(files?: File[]): Promise<void>;
274
273
  onWatcherStart(): Promise<void>;
275
274
  stopListRender(): Promise<void>;
276
- onWatcherRerun(files: string[], trigger: string): Promise<void>;
275
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
277
276
  onUserConsoleLog(log: UserConsoleLog): void;
278
277
  }
279
278
 
@@ -288,7 +287,7 @@ declare const ReportersMap: {
288
287
  };
289
288
  declare type BuiltinReporters = keyof typeof ReportersMap;
290
289
 
291
- declare type Reporter$1 = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
290
+ declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
292
291
  interface C8Options {
293
292
  /**
294
293
  * Enable coverage, pass `--coverage` to enable
@@ -323,7 +322,7 @@ interface C8Options {
323
322
  *
324
323
  * @default 'text'
325
324
  */
326
- reporter?: Arrayable$1<Reporter$1>;
325
+ reporter?: Arrayable<CoverageReporter>;
327
326
  /**
328
327
  * Exclude coverage under /node_modules/
329
328
  *
@@ -440,12 +439,12 @@ interface RuntimeContext {
440
439
  }
441
440
 
442
441
  interface Reporter {
443
- onInit(ctx: Vitest): void;
444
- onStart?: (files?: string[]) => Awaitable<void>;
442
+ onInit?(ctx: Vitest): void;
443
+ onCollected?: (files?: File[]) => Awaitable<void>;
445
444
  onFinished?: (files?: File[]) => Awaitable<void>;
446
- onTaskUpdate?: (pack: TaskResultPack) => Awaitable<void>;
445
+ onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
447
446
  onWatcherStart?: () => Awaitable<void>;
448
- onWatcherRerun?: (files: string[], trigger: string) => Awaitable<void>;
447
+ onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
449
448
  onServerRestart?: () => Awaitable<void>;
450
449
  onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
451
450
  }
@@ -695,7 +694,7 @@ interface WorkerRPC {
695
694
  onWorkerExit: (code?: number) => void;
696
695
  onUserLog: (log: UserConsoleLog) => void;
697
696
  onCollected: (files: File[]) => void;
698
- onTaskUpdate: (pack: TaskResultPack) => void;
697
+ onTaskUpdate: (pack: TaskResultPack[]) => void;
699
698
  snapshotSaved: (snapshot: SnapshotResult) => void;
700
699
  }
701
700
 
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-2115c609.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-7f57c252.js';
1
+ export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-b3412f83.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-80d9a771.js';
3
3
  export { f as fn, s as spies, a as spyOn } from './jest-mock-4a754991.js';
4
4
  export { assert, default as chai, should } from 'chai';
5
- import './index-7c024e16.js';
5
+ import './index-bf29f0e6.js';
6
6
  import 'url';
7
7
  import 'tty';
8
8
  import 'local-pkg';
package/dist/node.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
2
2
  import { RawSourceMap } from 'source-map-js';
3
- import { Arrayable as Arrayable$1 } from 'vitest';
4
3
  import { OptionsReceived } from 'pretty-format';
5
4
 
6
5
  declare abstract class BaseReporter implements Reporter {
@@ -12,10 +11,10 @@ declare abstract class BaseReporter implements Reporter {
12
11
  onInit(ctx: Vitest): void;
13
12
  relative(path: string): string;
14
13
  onFinished(files?: File[]): Promise<void>;
15
- onTaskUpdate(pack: TaskResultPack): void;
14
+ onTaskUpdate(packs: TaskResultPack[]): void;
16
15
  isFirstWatchRun: boolean;
17
16
  onWatcherStart(): Promise<void>;
18
- onWatcherRerun(files: string[], trigger: string): Promise<void>;
17
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
19
18
  onUserConsoleLog(log: UserConsoleLog): void;
20
19
  onServerRestart(): void;
21
20
  reportSummary(files: File[]): Promise<void>;
@@ -36,21 +35,21 @@ declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions)
36
35
  declare class DefaultReporter extends BaseReporter {
37
36
  renderer?: ReturnType<typeof createListRenderer>;
38
37
  rendererOptions: ListRendererOptions;
39
- onStart(): void;
38
+ onCollected(): void;
40
39
  onFinished(files?: File[]): Promise<void>;
41
40
  onWatcherStart(): Promise<void>;
42
41
  stopListRender(): Promise<void>;
43
- onWatcherRerun(files: string[], trigger: string): Promise<void>;
42
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
44
43
  onUserConsoleLog(log: UserConsoleLog): void;
45
44
  }
46
45
 
47
46
  declare class DotReporter extends BaseReporter {
48
47
  renderer?: ReturnType<typeof createListRenderer>;
49
- onStart(): void;
48
+ onCollected(): void;
50
49
  onFinished(files?: File[]): Promise<void>;
51
50
  onWatcherStart(): Promise<void>;
52
51
  stopListRender(): Promise<void>;
53
- onWatcherRerun(files: string[], trigger: string): Promise<void>;
52
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
54
53
  onUserConsoleLog(log: UserConsoleLog): void;
55
54
  }
56
55
 
@@ -65,7 +64,7 @@ declare const ReportersMap: {
65
64
  };
66
65
  declare type BuiltinReporters = keyof typeof ReportersMap;
67
66
 
68
- declare type Reporter$1 = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
67
+ declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
69
68
  interface C8Options {
70
69
  /**
71
70
  * Enable coverage, pass `--coverage` to enable
@@ -100,7 +99,7 @@ interface C8Options {
100
99
  *
101
100
  * @default 'text'
102
101
  */
103
- reporter?: Arrayable$1<Reporter$1>;
102
+ reporter?: Arrayable<CoverageReporter>;
104
103
  /**
105
104
  * Exclude coverage under /node_modules/
106
105
  *
@@ -159,12 +158,12 @@ interface Test extends TaskBase {
159
158
  declare type Task = Test | Suite | File;
160
159
 
161
160
  interface Reporter {
162
- onInit(ctx: Vitest): void;
163
- onStart?: (files?: string[]) => Awaitable<void>;
161
+ onInit?(ctx: Vitest): void;
162
+ onCollected?: (files?: File[]) => Awaitable<void>;
164
163
  onFinished?: (files?: File[]) => Awaitable<void>;
165
- onTaskUpdate?: (pack: TaskResultPack) => Awaitable<void>;
164
+ onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
166
165
  onWatcherStart?: () => Awaitable<void>;
167
- onWatcherRerun?: (files: string[], trigger: string) => Awaitable<void>;
166
+ onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
168
167
  onServerRestart?: () => Awaitable<void>;
169
168
  onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
170
169
  }
@@ -413,7 +412,7 @@ declare class StateManager {
413
412
  idMap: Record<string, Task>;
414
413
  taskFileMap: WeakMap<Task, File>;
415
414
  getFiles(keys?: string[]): File[];
416
- collectFiles(files: File[]): void;
415
+ collectFiles(files?: File[]): void;
417
416
  updateId(task: Task): void;
418
417
  updateTasks(packs: TaskResultPack[]): void;
419
418
  }
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { c as createVitest } from './index-b4f86684.js';
2
- import './index-7c024e16.js';
1
+ export { c as createVitest } from './index-1af8810e.js';
2
+ import './index-bf29f0e6.js';
3
3
  import 'url';
4
4
  import 'tty';
5
5
  import 'local-pkg';
@@ -11,10 +11,10 @@ import 'os';
11
11
  import 'util';
12
12
  import 'stream';
13
13
  import 'events';
14
- import './constants-5968a78c.js';
14
+ import './constants-080f26e8.js';
15
15
  import './magic-string.es-94000aea.js';
16
16
  import 'perf_hooks';
17
- import './diff-67678e1f.js';
17
+ import './diff-80c47cfa.js';
18
18
  import './index-648e7ab2.js';
19
19
  import './_commonjsHelpers-c9e3b764.js';
20
20
  import 'assert';