vitest 0.0.125 → 0.0.129

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
@@ -4,11 +4,11 @@ import { Buffer } from 'buffer';
4
4
  import path from 'path';
5
5
  import childProcess from 'child_process';
6
6
  import process$1 from 'process';
7
- import { m as mergeStream, g as getStream, c as crossSpawn } from './index-6e709f57.js';
7
+ import { m as mergeStream, g as getStream, c as crossSpawn } from './index-cce5de77.js';
8
8
  import require$$0, { constants } from 'os';
9
- import { s as signalExit } from './index-648e7ab2.js';
10
- import { e as ensurePackageInstalled } from './index-9fdde2e8.js';
11
- import { c as createVitest } from './index-37193236.js';
9
+ import { s as signalExit } from './index-cb02ee01.js';
10
+ import { e as ensurePackageInstalled } from './index-42a3a132.js';
11
+ import { c as createVitest } from './index-d30b5ed0.js';
12
12
  import './_commonjsHelpers-c9e3b764.js';
13
13
  import 'fs';
14
14
  import 'stream';
@@ -18,14 +18,14 @@ import 'url';
18
18
  import 'tty';
19
19
  import 'local-pkg';
20
20
  import 'vite';
21
- import './constants-8b3a9b31.js';
22
- import './magic-string.es-94000aea.js';
21
+ import './constants-868b9a2e.js';
22
+ import './magic-string.es-98a8bfa0.js';
23
23
  import 'perf_hooks';
24
- import './diff-3adb959a.js';
24
+ import './diff-be830986.js';
25
25
  import 'module';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
28
- import './index-e909c175.js';
28
+ import './index-a73f33e0.js';
29
29
 
30
30
  function toArr(any) {
31
31
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -1700,11 +1700,11 @@ function execa(file, args, options) {
1700
1700
  return mergePromise(spawned, handlePromiseOnce);
1701
1701
  }
1702
1702
 
1703
- var version = "0.0.125";
1703
+ var version = "0.0.129";
1704
1704
 
1705
1705
  const CLOSE_TIMEOUT = 1e3;
1706
1706
  const cli = cac("vitest");
1707
- 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("-t, --testNamePattern <pattern>", "run test names with the specified pattern").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file", { default: true }).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
+ 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("-t, --testNamePattern <pattern>", "run test names with the specified pattern").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads", { default: true }).option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file", { default: true }).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();
1708
1708
  cli.command("run [...filters]").action(run);
1709
1709
  cli.command("related [...filters]").action(runRelated);
1710
1710
  cli.command("watch [...filters]").action(dev);
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { k as resolve } from './index-9fdde2e8.js';
2
+ import { k as resolve } from './index-42a3a132.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}"];
@@ -30,4 +30,4 @@ const globalApis = [
30
30
  "afterEach"
31
31
  ];
32
32
 
33
- export { API_PATH as A, defaultExclude as a, defaultPort as b, distDir as c, defaultInclude as d, configFiles as e, globalApis as g };
33
+ export { API_PATH as A, defaultInclude as a, defaultExclude as b, distDir as c, defaultPort as d, configFiles as e, globalApis as g };
@@ -1,5 +1,5 @@
1
1
  import { existsSync, promises } from 'fs';
2
- import { o as notNullish, c, r as relative } from './index-9fdde2e8.js';
2
+ import { o as notNullish, c, r as relative } from './index-42a3a132.js';
3
3
 
4
4
  function Diff() {}
5
5
  Diff.prototype = {
package/dist/entry.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import fs, { promises } from 'fs';
2
- import { f as format_1, h as getSerializers, p as plugins_1, b as getState, j as equals, k as iterableEquality, l as subsetEquality, m as isA, J as JestChaiExpect, n as clearContext, o as defaultSuite, q as setHooks, r as getHooks, u as context, s as setState, x as getFn, e as vi } from './vi-56df0b20.js';
2
+ import { f as format_1, h as getSerializers, p as plugins_1, j as equals, b as getState, k as iterableEquality, l as subsetEquality, m as isA, J as JestChaiExpect, n as clearContext, o as defaultSuite, q as setHooks, r as getHooks, u as context, s as setState, x as getFn, e as vi } from './vi-fe26a646.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 { u as index, s as slash, v as getNames, c, t as toArray, r as relative, w as partitionSuiteChildren, x as hasTests, h as hasFailed } from './index-9fdde2e8.js';
8
+ import { u as index, s as slash, v as getNames, c, t as toArray, r as relative, w as partitionSuiteChildren, x as hasTests, h as hasFailed } from './index-42a3a132.js';
9
9
  import { r as rpc } from './rpc-8c7cc374.js';
10
- import { l as getOriginalPos, m as posToNumber, n as parseStacktrace, u as unifiedDiff } from './diff-3adb959a.js';
10
+ import { l as getOriginalPos, m as posToNumber, n as parseStacktrace, u as unifiedDiff } from './diff-be830986.js';
11
11
  import { performance as performance$1 } from 'perf_hooks';
12
12
  import { createHash } from 'crypto';
13
13
  import { format } from 'util';
14
- import './jest-mock-038a01b3.js';
14
+ import './jest-mock-30625866.js';
15
15
  import 'tinyspy';
16
16
  import 'url';
17
17
  import 'tty';
@@ -385,7 +385,7 @@ var chaiSubset = {exports: {}};
385
385
  var Subset = chaiSubset.exports;
386
386
 
387
387
  async function saveInlineSnapshots(snapshots) {
388
- const MagicString = (await import('./magic-string.es-94000aea.js')).default;
388
+ const MagicString = (await import('./magic-string.es-98a8bfa0.js')).default;
389
389
  const files = new Set(snapshots.map((i) => i.file));
390
390
  await Promise.all(Array.from(files).map(async (file) => {
391
391
  const map = await rpc().getSourceMap(file);
@@ -985,12 +985,11 @@ const getMatcherState = (assertion) => {
985
985
  iterableEquality,
986
986
  subsetEquality
987
987
  });
988
- const matcherState = __spreadProps(__spreadValues({
988
+ const matcherState = __spreadProps(__spreadValues({}, getState()), {
989
989
  isNot,
990
990
  utils: jestUtils,
991
991
  promise,
992
- equals
993
- }, getState()), {
992
+ equals,
994
993
  suppressedErrors: []
995
994
  });
996
995
  return {
@@ -1226,7 +1225,7 @@ async function setupGlobalEnv(config) {
1226
1225
  setupConsoleLogSpy();
1227
1226
  await setupChai();
1228
1227
  if (config.global)
1229
- (await import('./global-3b7dd162.js')).registerApiGlobally();
1228
+ (await import('./global-0254dd68.js')).registerApiGlobally();
1230
1229
  }
1231
1230
  function setupConsoleLogSpy() {
1232
1231
  const stdout = new Writable({
@@ -1274,7 +1273,8 @@ async function runSetupFiles(config) {
1274
1273
  }));
1275
1274
  }
1276
1275
 
1277
- function serializeError(val, seen = new WeakSet()) {
1276
+ const OBJECT_PROTO = Object.getPrototypeOf({});
1277
+ function serializeError(val, seen = new WeakMap()) {
1278
1278
  if (!val || typeof val === "string")
1279
1279
  return val;
1280
1280
  if (typeof val === "function")
@@ -1288,18 +1288,27 @@ function serializeError(val, seen = new WeakSet()) {
1288
1288
  if (typeof val.asymmetricMatch === "function")
1289
1289
  return `${val.toString()} ${format(val.sample)}`;
1290
1290
  if (seen.has(val))
1291
- return val;
1292
- seen.add(val);
1291
+ return seen.get(val);
1293
1292
  if (Array.isArray(val)) {
1294
- val = val.map((e) => {
1295
- return serializeError(e, seen);
1293
+ const clone = new Array(val.length);
1294
+ seen.set(val, clone);
1295
+ val.forEach((e, i) => {
1296
+ clone[i] = serializeError(e, seen);
1296
1297
  });
1298
+ return clone;
1297
1299
  } else {
1298
- Object.keys(val).forEach((key) => {
1299
- val[key] = serializeError(val[key], seen);
1300
- });
1300
+ const clone = Object.create(null);
1301
+ seen.set(val, clone);
1302
+ let obj = val;
1303
+ while (obj && obj !== OBJECT_PROTO) {
1304
+ Object.getOwnPropertyNames(obj).forEach((key) => {
1305
+ if (!(key in clone))
1306
+ clone[key] = serializeError(obj[key], seen);
1307
+ });
1308
+ obj = Object.getPrototypeOf(obj);
1309
+ }
1310
+ return clone;
1301
1311
  }
1302
- return val;
1303
1312
  }
1304
1313
  function processError(err) {
1305
1314
  if (!err)
@@ -1417,11 +1426,11 @@ async function callSuiteHook(suite, name, args) {
1417
1426
  if (name === "afterEach" && suite.suite)
1418
1427
  await callSuiteHook(suite.suite, name, args);
1419
1428
  }
1420
- const packs = [];
1429
+ const packs = new Map();
1421
1430
  let updateTimer;
1422
1431
  let previousUpdate;
1423
1432
  function updateTask(task) {
1424
- packs.push([task.id, task.result]);
1433
+ packs.set(task.id, task.result);
1425
1434
  clearTimeout(updateTimer);
1426
1435
  updateTimer = setTimeout(() => {
1427
1436
  previousUpdate = sendTasksUpdate();
@@ -1430,9 +1439,9 @@ function updateTask(task) {
1430
1439
  async function sendTasksUpdate() {
1431
1440
  clearTimeout(updateTimer);
1432
1441
  await previousUpdate;
1433
- if (packs.length) {
1434
- const p = rpc().onTaskUpdate(packs);
1435
- packs.length = 0;
1442
+ if (packs.size) {
1443
+ const p = rpc().onTaskUpdate(Array.from(packs));
1444
+ packs.clear();
1436
1445
  return p;
1437
1446
  }
1438
1447
  }
@@ -1,15 +1,15 @@
1
- import { g as globalApis } from './constants-8b3a9b31.js';
2
- import { i as index } from './index-7f52a6d6.js';
1
+ import { g as globalApis } from './constants-868b9a2e.js';
2
+ import { i as index } from './index-06712022.js';
3
3
  import 'url';
4
- import './index-9fdde2e8.js';
4
+ import './index-42a3a132.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
- import './vi-56df0b20.js';
9
- import './_commonjsHelpers-c9e3b764.js';
10
- import './jest-mock-038a01b3.js';
8
+ import './vi-fe26a646.js';
9
+ import './jest-mock-30625866.js';
11
10
  import 'chai';
12
11
  import 'tinyspy';
12
+ import './_commonjsHelpers-c9e3b764.js';
13
13
 
14
14
  function registerApiGlobally() {
15
15
  globalApis.forEach((api) => {
@@ -1,6 +1,6 @@
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-56df0b20.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-fe26a646.js';
2
2
  import chai, { assert, should } from 'chai';
3
- import { s as spies, a as spyOn, f as fn } from './jest-mock-038a01b3.js';
3
+ import { s as spies, i as isMockFunction, a as spyOn, f as fn } from './jest-mock-30625866.js';
4
4
 
5
5
  const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
6
6
  const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
@@ -29,6 +29,7 @@ var index = /*#__PURE__*/Object.freeze({
29
29
  chai: chai,
30
30
  expect: expect,
31
31
  spies: spies,
32
+ isMockFunction: isMockFunction,
32
33
  spyOn: spyOn,
33
34
  fn: fn,
34
35
  vitest: vitest,
@@ -319,14 +319,14 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
319
319
  `));
320
320
  if (!promptInstall)
321
321
  return false;
322
- const prompts = await import('./index-fa899e66.js').then(function (n) { return n.i; });
322
+ const prompts = await import('./index-93dcb598.js').then(function (n) { return n.i; });
323
323
  const { install } = await prompts.prompt({
324
324
  type: "confirm",
325
325
  name: "install",
326
326
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
327
327
  });
328
328
  if (install) {
329
- await (await import('./index-ce49e384.js')).installPackage(dependency, { dev: true });
329
+ await (await import('./index-42d44ee5.js')).installPackage(dependency, { dev: true });
330
330
  return true;
331
331
  }
332
332
  return false;
@@ -2,8 +2,8 @@ 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, m as mergeStream$1, a as getStream$1, b as crossSpawn$1 } from './index-6e709f57.js';
6
- import { a as signalExit, b as onetime$1 } from './index-648e7ab2.js';
5
+ import { p as pathKey, m as mergeStream$1, a as getStream$1, b as crossSpawn$1 } from './index-cce5de77.js';
6
+ import { a as signalExit, b as onetime$1 } from './index-cb02ee01.js';
7
7
  import require$$0$1 from 'os';
8
8
  import './_commonjsHelpers-c9e3b764.js';
9
9
  import 'buffer';
File without changes
File without changes
File without changes
File without changes