vitest 0.0.93 → 0.0.97

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/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import require$$0 from 'readline';
2
2
  import { EventEmitter } from 'events';
3
- import { c, e as ensurePackageInstalled } from './utils-576876dc.js';
4
- import { c as createVitest } from './index-880654a3.js';
3
+ import { c, e as ensurePackageInstalled } from './utils-70b78878.js';
4
+ import { c as createVitest } from './index-ca1a0bda.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
@@ -13,12 +13,12 @@ import 'util';
13
13
  import './constants-9cfa4d7b.js';
14
14
  import 'url';
15
15
  import 'perf_hooks';
16
- import './error-bf2213e4.js';
16
+ import './error-7405ce56.js';
17
17
  import 'source-map';
18
18
  import './index-5cc247ff.js';
19
19
  import 'assert';
20
20
  import 'worker_threads';
21
- import 'piscina';
21
+ import 'tinypool';
22
22
 
23
23
  function toArr(any) {
24
24
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -633,7 +633,7 @@ class CAC extends EventEmitter {
633
633
 
634
634
  const cac = (name = "") => new CAC(name);
635
635
 
636
- var version = "0.0.93";
636
+ var version = "0.0.97";
637
637
 
638
638
  const cli = cac("vitest");
639
639
  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").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
@@ -644,6 +644,7 @@ cli.command("watch [...filters]").action(dev);
644
644
  cli.command("dev [...filters]").action(dev);
645
645
  cli.command("[...filters]").action(dev);
646
646
  cli.parse();
647
+ const PROCESS_EXIT_TIMEOUT = 5e3;
647
648
  async function dev(cliFilters, argv) {
648
649
  if (argv.watch == null)
649
650
  argv.watch = !process.env.CI && !process.env.NODE_V8_COVERAGE;
@@ -675,6 +676,13 @@ async function run(cliFilters, options) {
675
676
  if (!ctx.config.watch)
676
677
  await ctx.close();
677
678
  }
679
+ if (!ctx.config.watch) {
680
+ const timer = setTimeout(() => {
681
+ console.error(c.red("Process hanging for 5 seconds after all tests are done. Exiting..."));
682
+ process.exit(1);
683
+ }, PROCESS_EXIT_TIMEOUT);
684
+ timer.unref();
685
+ }
678
686
  }
679
687
  function registerConsoleShortcuts(ctx) {
680
688
  if (process.stdin.isTTY) {
package/dist/entry.js CHANGED
@@ -6,11 +6,12 @@ import chai, { expect, util } from 'chai';
6
6
  import Subset from 'chai-subset';
7
7
  import path, { basename } from 'path';
8
8
  import { r as rpc, s as send } from './rpc-7de86f29.js';
9
- import { g as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, f as hasTests, h as hasFailed } from './utils-576876dc.js';
10
- import { u as unifiedDiff } from './error-bf2213e4.js';
9
+ import { g as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, f as hasTests, h as hasFailed } from './utils-70b78878.js';
10
+ import { u as unifiedDiff } from './error-7405ce56.js';
11
11
  import { performance } from 'perf_hooks';
12
12
  import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-b8c6cb53.js';
13
13
  import { n as nanoid } from './index-9e71c815.js';
14
+ import { format as format$1 } from 'util';
14
15
  import 'tty';
15
16
  import 'source-map';
16
17
 
@@ -2674,19 +2675,19 @@ let PLUGINS$1 = [
2674
2675
  ];
2675
2676
  const getSerializers = () => PLUGINS$1;
2676
2677
 
2677
- var __defProp$1 = Object.defineProperty;
2678
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
2679
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
2680
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
2681
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2682
- var __spreadValues$1 = (a, b) => {
2678
+ var __defProp$2 = Object.defineProperty;
2679
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
2680
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
2681
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
2682
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2683
+ var __spreadValues$2 = (a, b) => {
2683
2684
  for (var prop in b || (b = {}))
2684
- if (__hasOwnProp$1.call(b, prop))
2685
- __defNormalProp$1(a, prop, b[prop]);
2686
- if (__getOwnPropSymbols$1)
2687
- for (var prop of __getOwnPropSymbols$1(b)) {
2688
- if (__propIsEnum$1.call(b, prop))
2689
- __defNormalProp$1(a, prop, b[prop]);
2685
+ if (__hasOwnProp$2.call(b, prop))
2686
+ __defNormalProp$2(a, prop, b[prop]);
2687
+ if (__getOwnPropSymbols$2)
2688
+ for (var prop of __getOwnPropSymbols$2(b)) {
2689
+ if (__propIsEnum$2.call(b, prop))
2690
+ __defNormalProp$2(a, prop, b[prop]);
2690
2691
  }
2691
2692
  return a;
2692
2693
  };
@@ -2722,7 +2723,7 @@ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith
2722
2723
  const escapeRegex = true;
2723
2724
  const printFunctionName = false;
2724
2725
  function serialize(val, indent = 2, formatOverrides = {}) {
2725
- return normalizeNewlines(format_1(val, __spreadValues$1({
2726
+ return normalizeNewlines(format_1(val, __spreadValues$2({
2726
2727
  escapeRegex,
2727
2728
  indent,
2728
2729
  plugins: getSerializers(),
@@ -2753,6 +2754,22 @@ ${snapshots.join("\n\n")}
2753
2754
  `);
2754
2755
  }
2755
2756
 
2757
+ var __defProp$1 = Object.defineProperty;
2758
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
2759
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
2760
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
2761
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2762
+ var __spreadValues$1 = (a, b) => {
2763
+ for (var prop in b || (b = {}))
2764
+ if (__hasOwnProp$1.call(b, prop))
2765
+ __defNormalProp$1(a, prop, b[prop]);
2766
+ if (__getOwnPropSymbols$1)
2767
+ for (var prop of __getOwnPropSymbols$1(b)) {
2768
+ if (__propIsEnum$1.call(b, prop))
2769
+ __defNormalProp$1(a, prop, b[prop]);
2770
+ }
2771
+ return a;
2772
+ };
2756
2773
  class SnapshotState {
2757
2774
  constructor(snapshotPath, options) {
2758
2775
  this._snapshotPath = snapshotPath;
@@ -2769,7 +2786,9 @@ class SnapshotState {
2769
2786
  this.unmatched = 0;
2770
2787
  this._updateSnapshot = options.updateSnapshot;
2771
2788
  this.updated = 0;
2772
- this._snapshotFormat = options.snapshotFormat || {};
2789
+ this._snapshotFormat = __spreadValues$1({
2790
+ printBasicPrototype: false
2791
+ }, options.snapshotFormat);
2773
2792
  }
2774
2793
  markSnapshotsAsCheckedForTest(testName) {
2775
2794
  this._uncheckedKeys.forEach((uncheckedKey) => {
@@ -2918,7 +2937,10 @@ class SnapshotClient {
2918
2937
  assert(received, message, inlineSnapshot) {
2919
2938
  if (!this.test)
2920
2939
  throw new Error("Snapshot cannot be used outside of test");
2921
- const testName = getNames(this.test).slice(1).join(" > ");
2940
+ const testName = [
2941
+ ...getNames(this.test).slice(1),
2942
+ ...message ? [message] : []
2943
+ ].join(" > ");
2922
2944
  const { actual, expected, key, pass } = this.snapshotState.match({
2923
2945
  testName,
2924
2946
  received,
@@ -3413,7 +3435,7 @@ const JestChaiExpect = (chai, utils) => {
3413
3435
  const expected = args[0];
3414
3436
  const actual = utils.flag(this, "object");
3415
3437
  if (hasAsymmetric(expected)) {
3416
- this.assert(equals(actual, expected, void 0, true), "not match with #{this}", "should not match with #{this}", true);
3438
+ this.assert(equals(actual, expected, void 0, true), "not match with #{act}", "should not match with #{act}", actual, expected);
3417
3439
  } else {
3418
3440
  _super.apply(this, args);
3419
3441
  }
@@ -3424,7 +3446,7 @@ const JestChaiExpect = (chai, utils) => {
3424
3446
  const expected = args[0];
3425
3447
  const actual = utils.flag(this, "object");
3426
3448
  if (hasAsymmetric(expected)) {
3427
- this.assert(equals(actual, expected), "not match with #{this}", "should not match with #{this}", true);
3449
+ this.assert(equals(actual, expected), "not match with #{exp}", "should not match with #{exp}", actual, expected);
3428
3450
  } else {
3429
3451
  _super.apply(this, args);
3430
3452
  }
@@ -3437,7 +3459,7 @@ const JestChaiExpect = (chai, utils) => {
3437
3459
  return this.chaiEqual(expected);
3438
3460
  });
3439
3461
  def("toBe", function(expected) {
3440
- return this.chaiEqual(expected);
3462
+ return this.equal(expected);
3441
3463
  });
3442
3464
  def("toMatchObject", function(expected) {
3443
3465
  return this.containSubset(expected);
@@ -3781,7 +3803,7 @@ async function setupGlobalEnv(config) {
3781
3803
  setupConsoleLogSpy();
3782
3804
  await setupChai();
3783
3805
  if (config.global)
3784
- (await import('./global-c40aeb86.js')).registerApiGlobally();
3806
+ (await import('./global-473089f7.js')).registerApiGlobally();
3785
3807
  }
3786
3808
  function setupConsoleLogSpy() {
3787
3809
  const stdout = new Writable({
@@ -3841,6 +3863,8 @@ function serializeError(val) {
3841
3863
  return "Promise";
3842
3864
  if (typeof Element !== "undefined" && val instanceof Element)
3843
3865
  return val.tagName;
3866
+ if (typeof val.asymmetricMatch === "function")
3867
+ return `${val.toString()} ${format$1(val.sample)}`;
3844
3868
  Object.keys(val).forEach((key) => {
3845
3869
  val[key] = serializeError(val[key]);
3846
3870
  });
@@ -1,6 +1,7 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { relative } from 'path';
3
- import { d as notNullish, c } from './utils-576876dc.js';
3
+ import { format } from 'util';
4
+ import { d as notNullish, c } from './utils-70b78878.js';
4
5
  import { SourceMapConsumer } from 'source-map';
5
6
 
6
7
  function Diff() {}
@@ -1266,12 +1267,14 @@ async function printStack(ctx, stack, highlight, onStack) {
1266
1267
  const pos = await getSourcePos(ctx, frame) || frame;
1267
1268
  const color = frame === highlight ? c.yellow : c.gray;
1268
1269
  const path = relative(ctx.config.root, frame.file);
1269
- ctx.console.log(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
1270
+ if (!ctx.config.silent)
1271
+ ctx.console.log(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
1270
1272
  await (onStack == null ? void 0 : onStack(frame, pos));
1271
1273
  if (frame.file in ctx.state.filesMap)
1272
1274
  break;
1273
1275
  }
1274
- ctx.console.log();
1276
+ if (!ctx.config.silent)
1277
+ ctx.console.log();
1275
1278
  }
1276
1279
  function getOriginalPos(map, { line, column }) {
1277
1280
  return new Promise((resolve) => {
@@ -1338,7 +1341,7 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
1338
1341
  return res.join("\n");
1339
1342
  }
1340
1343
  function stringify(obj) {
1341
- return String(obj);
1344
+ return format(obj);
1342
1345
  }
1343
1346
  const stackFnCallRE = /at (.*) \((.+):(\d+):(\d+)\)$/;
1344
1347
  const stackBarePathRE = /at ?(.*) (.+):(\d+):(\d+)$/;
@@ -1373,35 +1376,34 @@ function unifiedDiff(actual, expected) {
1373
1376
  if (expectedLinesCount >= diffLimit)
1374
1377
  return;
1375
1378
  expectedLinesCount++;
1379
+ line = line[0] + " " + line.slice(1);
1376
1380
  const isLastLine = expectedLinesCount === diffLimit;
1377
- return indent + c.green(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
1381
+ return indent + c.red(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
1378
1382
  }
1379
1383
  if (line[0] === "-") {
1380
1384
  if (actualLinesCount >= diffLimit)
1381
1385
  return;
1382
1386
  actualLinesCount++;
1387
+ line = line[0] + " " + line.slice(1);
1383
1388
  const isLastLine = actualLinesCount === diffLimit;
1384
- return indent + c.red(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
1389
+ return indent + c.green(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
1385
1390
  }
1386
1391
  if (line.match(/@@/))
1387
1392
  return "--";
1388
1393
  if (line.match(/\\ No newline/))
1389
1394
  return null;
1390
- return indent + line;
1395
+ return indent + " " + line;
1391
1396
  }
1392
1397
  const msg = createPatch("string", actual, expected);
1393
1398
  const lines = msg.split("\n").splice(5);
1394
1399
  return `
1395
- ${indent}${c.red("- actual")}
1396
- ${indent}${c.green("+ expected")}
1400
+ ${indent}${c.green("- expected")}
1401
+ ${indent}${c.red("+ actual")}
1397
1402
 
1398
1403
  ${lines.map(cleanUp).filter(notBlank).join("\n")}`;
1399
1404
  }
1400
1405
  function formatLine(line) {
1401
- const lineLimitLength = 50;
1402
- if (line.length > lineLimitLength)
1403
- return `${line.slice(0, lineLimitLength)} ${c.dim("[...truncated]")}`;
1404
- return line;
1406
+ return cliTruncate(line, (process.stdout.columns || 40) - 1);
1405
1407
  }
1406
1408
  function renderTruncateMessage(indent) {
1407
1409
  return `
@@ -1,5 +1,5 @@
1
1
  import { g as globalApis } from './constants-9cfa4d7b.js';
2
- import { i as index } from './index-708135df.js';
2
+ import { i as index } from './index-368448f4.js';
3
3
  import 'path';
4
4
  import 'url';
5
5
  import './suite-b8c6cb53.js';
@@ -1,7 +1,7 @@
1
1
  import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-b8c6cb53.js';
2
2
  import chai, { util, assert, should, expect } from 'chai';
3
3
  import * as tinyspy from 'tinyspy';
4
- import { spy, spyOn as spyOn$1 } from 'tinyspy';
4
+ import { spies } from 'tinyspy';
5
5
 
6
6
  const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
7
7
  const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
@@ -136,7 +136,8 @@ class FakeTimers {
136
136
  const spyFactory = (spyType, resultBuilder) => {
137
137
  return (cb, ms = 0) => {
138
138
  const id = ++this._spyid;
139
- const nestedMs = ms + (this._nestedTime[this._scopeId] ?? 0);
139
+ const nestedTo = Object.entries(this._nestedTime).filter(([key]) => Number(key) <= this._scopeId);
140
+ const nestedMs = nestedTo.reduce((total, [, ms2]) => total + ms2, ms);
140
141
  const call = { id, cb, ms, nestedMs, scopeId: this._scopeId };
141
142
  const task = { type: spyType, call, nested: this._isNested };
142
143
  this.pushTask(task);
@@ -306,6 +307,24 @@ class VitestUtils {
306
307
  getTimerCount() {
307
308
  return this._timers.getTimerCount();
308
309
  }
310
+ isMockFunction(fn2) {
311
+ return typeof fn2 === "function" && "__isSpy" in fn2 && fn2.__isSpy;
312
+ }
313
+ clearAllMocks() {
314
+ spies.forEach((spy) => {
315
+ spy.reset();
316
+ });
317
+ }
318
+ resetAllMocks() {
319
+ spies.forEach((spy) => {
320
+ spy.reset();
321
+ });
322
+ }
323
+ restoreAllMocks() {
324
+ spies.forEach((spy) => {
325
+ spy.restore();
326
+ });
327
+ }
309
328
  }
310
329
  const vitest = new VitestUtils();
311
330
  const vi = vitest;
@@ -324,10 +343,10 @@ var index = /*#__PURE__*/Object.freeze({
324
343
  should: should,
325
344
  expect: expect,
326
345
  chai: chai,
327
- spy: spy,
328
- spyOn: spyOn$1,
346
+ spyOn: spyOn,
347
+ fn: fn,
329
348
  vitest: vitest,
330
349
  vi: vi
331
350
  });
332
351
 
333
- export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, vi as e, index as i, vitest as v };
352
+ export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, vi as e, fn as f, index as i, spyOn as s, vitest as v };
@@ -5,13 +5,13 @@ import { promises } from 'fs';
5
5
  import fg from 'fast-glob';
6
6
  import require$$0 from 'util';
7
7
  import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-9cfa4d7b.js';
8
- import { c, g as getNames, s as slash, a as getTests, b as getSuites, n as noop, t as toArray, h as hasFailed } from './utils-576876dc.js';
8
+ import { c, g as getNames, s as slash, a as getTests, b as getSuites, n as noop, t as toArray, h as hasFailed } from './utils-70b78878.js';
9
9
  import { performance } from 'perf_hooks';
10
- import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-bf2213e4.js';
10
+ import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-7405ce56.js';
11
11
  import { o as onetime, s as signalExit } from './index-5cc247ff.js';
12
12
  import { MessageChannel } from 'worker_threads';
13
13
  import { pathToFileURL } from 'url';
14
- import Piscina from 'piscina';
14
+ import { Tinypool } from 'tinypool';
15
15
 
16
16
  /*
17
17
  How it works:
@@ -4968,7 +4968,6 @@ class ConsoleReporter {
4968
4968
  this.ctx = ctx;
4969
4969
  this.start = 0;
4970
4970
  this.end = 0;
4971
- this.console = globalThis.console;
4972
4971
  this.isFirstWatchRun = true;
4973
4972
  const mode = ctx.config.watch ? c.yellow(" DEV ") : c.cyan(" RUN ");
4974
4973
  this.log(`
@@ -4979,12 +4978,12 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
4979
4978
  log(...args) {
4980
4979
  if (this.ctx.config.silent)
4981
4980
  return;
4982
- this.console.log(...args);
4981
+ this.ctx.console.log(...args);
4983
4982
  }
4984
4983
  error(...args) {
4985
4984
  if (this.ctx.config.silent)
4986
4985
  return;
4987
- this.console.error(...args);
4986
+ this.ctx.console.error(...args);
4988
4987
  }
4989
4988
  relative(path) {
4990
4989
  return relative(this.ctx.config.root, path);
@@ -5092,9 +5091,11 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
5092
5091
  async onWatcherRerun(files, trigger) {
5093
5092
  await this.stopListRender();
5094
5093
  this.watchFilters = files;
5095
- this.console.clear();
5096
- this.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
5094
+ if (!this.ctx.config.silent) {
5095
+ this.ctx.console.clear();
5096
+ this.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
5097
5097
  `));
5098
+ }
5098
5099
  }
5099
5100
  async stopListRender() {
5100
5101
  var _a;
@@ -5230,7 +5231,7 @@ function createPool(ctx) {
5230
5231
  else
5231
5232
  return createFakePool(ctx);
5232
5233
  }
5233
- const workerPath = new URL("./dist/worker.js", pathToFileURL(distDir)).href;
5234
+ const workerPath = pathToFileURL(resolve(distDir, "./worker.js")).href;
5234
5235
  function createFakePool(ctx) {
5235
5236
  const runWithFiles = (name) => {
5236
5237
  return async (files, invalidates) => {
@@ -5263,7 +5264,7 @@ function createWorkerPool(ctx) {
5263
5264
  options.maxThreads = ctx.config.maxThreads;
5264
5265
  if (ctx.config.minThreads != null)
5265
5266
  options.minThreads = ctx.config.minThreads;
5266
- const piscina = new Piscina(options);
5267
+ const pool = new Tinypool(options);
5267
5268
  const runWithFiles = (name) => {
5268
5269
  return async (files, invalidates) => {
5269
5270
  await Promise.all(files.map(async (file) => {
@@ -5274,7 +5275,7 @@ function createWorkerPool(ctx) {
5274
5275
  files: [file],
5275
5276
  invalidates
5276
5277
  };
5277
- await piscina.run(data, { transferList: [workerPort], name });
5278
+ await pool.run(data, { transferList: [workerPort], name });
5278
5279
  port.close();
5279
5280
  workerPort.close();
5280
5281
  }));
@@ -5283,7 +5284,7 @@ function createWorkerPool(ctx) {
5283
5284
  return {
5284
5285
  runTests: runWithFiles("run"),
5285
5286
  collectTests: runWithFiles("collect"),
5286
- close: () => piscina.destroy()
5287
+ close: () => pool.destroy()
5287
5288
  };
5288
5289
  }
5289
5290
  function createChannel(ctx) {
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import { Formatter } from 'picocolors/types';
2
2
  import { OptionsReceived } from 'pretty-format';
3
3
  import { MessagePort } from 'worker_threads';
4
4
  export { assert, default as chai, expect, should } from 'chai';
5
- export { spy, spyOn } from 'tinyspy';
6
5
 
7
6
  declare const EXPECTED_COLOR: Formatter;
8
7
  declare const RECEIVED_COLOR: Formatter;
@@ -470,8 +469,6 @@ interface RpcMap {
470
469
  onCollected: [[files: File[]], void];
471
470
  onFinished: [[], void];
472
471
  onTaskUpdate: [[pack: TaskResultPack], void];
473
- onWatcherStart: [[], void];
474
- onWatcherRerun: [[files: string[], trigger: string], void];
475
472
  snapshotSaved: [[snapshot: SnapshotResult], void];
476
473
  }
477
474
  declare type RpcCall = <T extends keyof RpcMap>(method: T, ...args: RpcMap[T][0]) => Promise<RpcMap[T][1]>;
@@ -631,21 +628,25 @@ declare function fn<TArgs extends any[] = any[], R = any>(): JestMockCompatFn<TA
631
628
  declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): JestMockCompatFn<TArgs, R>;
632
629
 
633
630
  declare class VitestUtils {
634
- spyOn: typeof spyOn;
635
- fn: typeof fn;
636
- mock: (path: string) => string;
637
631
  private _timers;
638
632
  constructor();
639
633
  useFakeTimers(): void;
640
634
  useRealTimers(): void;
641
- runOnlyPendingTimers(): void;
642
- runAllTimers(): void;
643
- advanceTimersByTime(ms: number): void;
644
- advanceTimersToNextTimer(): void;
645
- runAllTicks(): void;
635
+ runOnlyPendingTimers(): void | Promise<void>;
636
+ runAllTimers(): void | Promise<void>;
637
+ advanceTimersByTime(ms: number): void | Promise<void>;
638
+ advanceTimersToNextTimer(): void | Promise<void>;
639
+ runAllTicks(): void | Promise<void>;
646
640
  setSystemTime(time?: number | Date): void;
647
641
  getRealSystemTime(): number;
648
642
  getTimerCount(): number;
643
+ spyOn: typeof spyOn;
644
+ fn: typeof fn;
645
+ mock: (path: string) => string;
646
+ isMockFunction(fn: any): any;
647
+ clearAllMocks(): void;
648
+ resetAllMocks(): void;
649
+ restoreAllMocks(): void;
649
650
  }
650
651
  declare const vitest: VitestUtils;
651
652
  declare const vi: VitestUtils;
@@ -721,4 +722,4 @@ declare global {
721
722
  }
722
723
  }
723
724
 
724
- export { ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, suite, test, vi, vitest };
725
+ export { ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, fn, it, spyOn, suite, test, vi, vitest };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { d as describe, i as it, s as suite, t as test } from './suite-b8c6cb53.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as vi, v as vitest } from './index-708135df.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, f as fn, s as spyOn, e as vi, v as vitest } from './index-368448f4.js';
3
3
  export { assert, default as chai, expect, should } from 'chai';
4
- export { spy, spyOn } from 'tinyspy';
5
4
  import './index-9e71c815.js';
5
+ import 'tinyspy';
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- export { c as createVitest } from './index-880654a3.js';
1
+ export { c as createVitest } from './index-ca1a0bda.js';
2
2
  import 'path';
3
3
  import 'vite';
4
4
  import 'process';
@@ -7,14 +7,14 @@ import 'fast-glob';
7
7
  import 'util';
8
8
  import './constants-9cfa4d7b.js';
9
9
  import 'url';
10
- import './utils-576876dc.js';
10
+ import './utils-70b78878.js';
11
11
  import 'tty';
12
12
  import 'local-pkg';
13
13
  import 'perf_hooks';
14
- import './error-bf2213e4.js';
14
+ import './error-7405ce56.js';
15
15
  import 'source-map';
16
16
  import './index-5cc247ff.js';
17
17
  import 'assert';
18
18
  import 'events';
19
19
  import 'worker_threads';
20
- import 'piscina';
20
+ import 'tinypool';
@@ -153,7 +153,7 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
153
153
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
154
154
  });
155
155
  if (install) {
156
- await (await import('./index-e7a421bb.js')).installPackage(dependency);
156
+ await (await import('./index-e7a421bb.js')).installPackage(dependency, { dev: true });
157
157
  return true;
158
158
  }
159
159
  return false;
package/dist/utils.js CHANGED
@@ -1,3 +1,3 @@
1
- export { e as ensurePackageInstalled, g as getNames, b as getSuites, j as getTasks, a as getTests, h as hasFailed, f as hasTests, i as interpretOnlyMode, n as noop, d as notNullish, p as partitionSuiteChildren, s as slash, t as toArray } from './utils-576876dc.js';
1
+ export { e as ensurePackageInstalled, g as getNames, b as getSuites, j as getTasks, a as getTests, h as hasFailed, f as hasTests, i as interpretOnlyMode, n as noop, d as notNullish, p as partitionSuiteChildren, s as slash, t as toArray } from './utils-70b78878.js';
2
2
  import 'local-pkg';
3
3
  import 'tty';