vitest 0.0.126 → 0.0.127

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-4cd25949.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-e04b9e4c.js';
9
+ import { s as signalExit } from './index-7975be53.js';
10
+ import { e as ensurePackageInstalled } from './index-f0488a5d.js';
11
+ import { c as createVitest } from './index-05648ba5.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-8b3a9b31.js';
21
+ import './constants-2cd49e0a.js';
22
22
  import './magic-string.es-94000aea.js';
23
23
  import 'perf_hooks';
24
- import './diff-3adb959a.js';
24
+ import './diff-711cddf1.js';
25
25
  import 'module';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
@@ -1700,7 +1700,7 @@ function execa(file, args, options) {
1700
1700
  return mergePromise(spawned, handlePromiseOnce);
1701
1701
  }
1702
1702
 
1703
- var version = "0.0.126";
1703
+ var version = "0.0.127";
1704
1704
 
1705
1705
  const CLOSE_TIMEOUT = 1e3;
1706
1706
  const cli = cac("vitest");
@@ -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-f0488a5d.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-9fdde2e8.js';
2
+ import { o as notNullish, c, r as relative } from './index-f0488a5d.js';
3
3
 
4
4
  function Diff() {}
5
5
  Diff.prototype = {
package/dist/entry.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import fs, { promises } from 'fs';
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-5ff3926d.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-02a9c349.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-f0488a5d.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-711cddf1.js';
11
11
  import { performance as performance$1 } from 'perf_hooks';
12
12
  import { createHash } from 'crypto';
13
13
  import { format } from 'util';
@@ -1225,7 +1225,7 @@ async function setupGlobalEnv(config) {
1225
1225
  setupConsoleLogSpy();
1226
1226
  await setupChai();
1227
1227
  if (config.global)
1228
- (await import('./global-eb23b22e.js')).registerApiGlobally();
1228
+ (await import('./global-60f865bb.js')).registerApiGlobally();
1229
1229
  }
1230
1230
  function setupConsoleLogSpy() {
1231
1231
  const stdout = new Writable({
@@ -1273,7 +1273,8 @@ async function runSetupFiles(config) {
1273
1273
  }));
1274
1274
  }
1275
1275
 
1276
- function serializeError(val, seen = new WeakSet()) {
1276
+ const OBJECT_PROTO = Object.getPrototypeOf({});
1277
+ function serializeError(val, seen = new WeakMap()) {
1277
1278
  if (!val || typeof val === "string")
1278
1279
  return val;
1279
1280
  if (typeof val === "function")
@@ -1287,18 +1288,27 @@ function serializeError(val, seen = new WeakSet()) {
1287
1288
  if (typeof val.asymmetricMatch === "function")
1288
1289
  return `${val.toString()} ${format(val.sample)}`;
1289
1290
  if (seen.has(val))
1290
- return val;
1291
- seen.add(val);
1291
+ return seen.get(val);
1292
1292
  if (Array.isArray(val)) {
1293
- val = val.map((e) => {
1294
- 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);
1295
1297
  });
1298
+ return clone;
1296
1299
  } else {
1297
- Object.keys(val).forEach((key) => {
1298
- val[key] = serializeError(val[key], seen);
1299
- });
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;
1300
1311
  }
1301
- return val;
1302
1312
  }
1303
1313
  function processError(err) {
1304
1314
  if (!err)
@@ -1307,9 +1317,9 @@ function processError(err) {
1307
1317
  err.stackStr = String(err.stack);
1308
1318
  if (err.name)
1309
1319
  err.nameStr = String(err.name);
1310
- if (typeof err.expected !== "string")
1320
+ if (err.expected && typeof err.expected !== "string")
1311
1321
  err.expected = stringify(err.expected);
1312
- if (typeof err.actual !== "string")
1322
+ if (err.actual && typeof err.actual !== "string")
1313
1323
  err.actual = stringify(err.actual);
1314
1324
  return serializeError(err);
1315
1325
  }
@@ -1416,11 +1426,11 @@ async function callSuiteHook(suite, name, args) {
1416
1426
  if (name === "afterEach" && suite.suite)
1417
1427
  await callSuiteHook(suite.suite, name, args);
1418
1428
  }
1419
- const packs = [];
1429
+ const packs = new Map();
1420
1430
  let updateTimer;
1421
1431
  let previousUpdate;
1422
1432
  function updateTask(task) {
1423
- packs.push([task.id, task.result]);
1433
+ packs.set(task.id, task.result);
1424
1434
  clearTimeout(updateTimer);
1425
1435
  updateTimer = setTimeout(() => {
1426
1436
  previousUpdate = sendTasksUpdate();
@@ -1429,9 +1439,9 @@ function updateTask(task) {
1429
1439
  async function sendTasksUpdate() {
1430
1440
  clearTimeout(updateTimer);
1431
1441
  await previousUpdate;
1432
- if (packs.length) {
1433
- const p = rpc().onTaskUpdate(packs);
1434
- packs.length = 0;
1442
+ if (packs.size) {
1443
+ const p = rpc().onTaskUpdate(Array.from(packs));
1444
+ packs.clear();
1435
1445
  return p;
1436
1446
  }
1437
1447
  }
@@ -1,11 +1,11 @@
1
- import { g as globalApis } from './constants-8b3a9b31.js';
2
- import { i as index } from './index-4b6e78b4.js';
1
+ import { g as globalApis } from './constants-2cd49e0a.js';
2
+ import { i as index } from './index-de2249ec.js';
3
3
  import 'url';
4
- import './index-9fdde2e8.js';
4
+ import './index-f0488a5d.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
- import './vi-5ff3926d.js';
8
+ import './vi-02a9c349.js';
9
9
  import './jest-mock-30625866.js';
10
10
  import 'chai';
11
11
  import 'tinyspy';
@@ -1,5 +1,5 @@
1
1
  import fs$8, { promises, existsSync } from 'fs';
2
- 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, e as ensurePackageInstalled } from './index-9fdde2e8.js';
2
+ 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, e as ensurePackageInstalled } from './index-f0488a5d.js';
3
3
  import { createServer, mergeConfig } from 'vite';
4
4
  import path$a from 'path';
5
5
  import process$1 from 'process';
@@ -7,11 +7,11 @@ 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-8b3a9b31.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-2cd49e0a.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-3adb959a.js';
14
- import { o as onetime, s as signalExit } from './index-648e7ab2.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-711cddf1.js';
14
+ import { o as onetime, s as signalExit } from './index-7975be53.js';
15
15
  import { createRequire } from 'module';
16
16
  import { pathToFileURL } from 'url';
17
17
  import { MessageChannel } from 'worker_threads';
@@ -8400,7 +8400,7 @@ async function createVitest(options, viteOverrides = {}) {
8400
8400
  await ctx.setServer(options, server2);
8401
8401
  haveStarted = true;
8402
8402
  if (options.api)
8403
- (await import('./setup-b0d2ca33.js')).setup(ctx);
8403
+ (await import('./setup-3d1395ff.js')).setup(ctx);
8404
8404
  }
8405
8405
  },
8406
8406
  MocksPlugin(),
@@ -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-4cd25949.js';
6
+ import { a as signalExit, b as onetime$1 } from './index-7975be53.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
@@ -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-5ff3926d.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-02a9c349.js';
2
2
  import chai, { assert, should } from 'chai';
3
3
  import { s as spies, i as isMockFunction, a as spyOn, f as fn } from './jest-mock-30625866.js';
4
4
 
@@ -326,7 +326,7 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
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-26cb6e63.js')).installPackage(dependency, { dev: true });
330
330
  return true;
331
331
  }
332
332
  return false;
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-5ff3926d.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-4b6e78b4.js';
1
+ export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-02a9c349.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-de2249ec.js';
3
3
  export { f as fn, i as isMockFunction, s as spies, a as spyOn } from './jest-mock-30625866.js';
4
4
  export { assert, default as chai, should } from 'chai';
5
- import './index-9fdde2e8.js';
5
+ import './index-f0488a5d.js';
6
6
  import 'url';
7
7
  import 'tty';
8
8
  import 'local-pkg';
package/dist/node.js CHANGED
@@ -1,6 +1,6 @@
1
- export { c as createVitest } from './index-e04b9e4c.js';
1
+ export { c as createVitest } from './index-05648ba5.js';
2
2
  import 'fs';
3
- import './index-9fdde2e8.js';
3
+ import './index-f0488a5d.js';
4
4
  import 'url';
5
5
  import 'tty';
6
6
  import 'local-pkg';
@@ -11,11 +11,11 @@ import 'os';
11
11
  import 'util';
12
12
  import 'stream';
13
13
  import 'events';
14
- import './constants-8b3a9b31.js';
14
+ import './constants-2cd49e0a.js';
15
15
  import './magic-string.es-94000aea.js';
16
16
  import 'perf_hooks';
17
- import './diff-3adb959a.js';
18
- import './index-648e7ab2.js';
17
+ import './diff-711cddf1.js';
18
+ import './index-7975be53.js';
19
19
  import './_commonjsHelpers-c9e3b764.js';
20
20
  import 'assert';
21
21
  import 'module';
@@ -9,10 +9,10 @@ import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import require$$7 from 'url';
12
- import { A as API_PATH } from './constants-8b3a9b31.js';
12
+ import { A as API_PATH } from './constants-2cd49e0a.js';
13
13
  import { s as shouldExternalize } from './externalize-2f63779d.js';
14
- import { o as interpretSourcePos, n as parseStacktrace } from './diff-3adb959a.js';
15
- import './index-9fdde2e8.js';
14
+ import { o as interpretSourcePos, n as parseStacktrace } from './diff-711cddf1.js';
15
+ import './index-f0488a5d.js';
16
16
  import 'tty';
17
17
  import 'local-pkg';
18
18
  import 'path';
@@ -1,4 +1,4 @@
1
- import { n as noop, i as isObject } from './index-9fdde2e8.js';
1
+ import { n as noop, i as isObject } from './index-f0488a5d.js';
2
2
  import { i as isMockFunction, a as spyOn, f as fn, s as spies } from './jest-mock-30625866.js';
3
3
  import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-c9e3b764.js';
4
4
 
@@ -2808,6 +2808,20 @@ const JestChaiExpect = (chai, utils) => {
2808
2808
  def("chaiEqual", function(...args) {
2809
2809
  return chaiEqual.apply(this, args);
2810
2810
  });
2811
+ ["throw", "throws", "Throw"].forEach((m) => {
2812
+ utils.overwriteMethod(chai.Assertion.prototype, m, (_super) => {
2813
+ return function(...args) {
2814
+ const promise = utils.flag(this, "promise");
2815
+ const object = utils.flag(this, "object");
2816
+ if (promise === "rejects") {
2817
+ utils.flag(this, "object", () => {
2818
+ throw object;
2819
+ });
2820
+ }
2821
+ _super.apply(this, args);
2822
+ };
2823
+ });
2824
+ });
2811
2825
  utils.overwriteMethod(chai.Assertion.prototype, "equal", (_super) => {
2812
2826
  return function(...args) {
2813
2827
  const expected = args[0];
@@ -3033,7 +3047,7 @@ const JestChaiExpect = (chai, utils) => {
3033
3047
  utils.flag(this, "object", value);
3034
3048
  return result.call(this, ...args);
3035
3049
  }, (err) => {
3036
- throw new Error(`promise rejected ${err} instead of resolving`);
3050
+ throw new Error(`promise rejected "${err}" instead of resolving`);
3037
3051
  });
3038
3052
  };
3039
3053
  }
@@ -3051,7 +3065,7 @@ const JestChaiExpect = (chai, utils) => {
3051
3065
  return result instanceof chai.Assertion ? proxy : result;
3052
3066
  return async (...args) => {
3053
3067
  return wrapper.then((value) => {
3054
- throw new Error(`promise resolved ${value} instead of rejecting`);
3068
+ throw new Error(`promise resolved "${value}" instead of rejecting`);
3055
3069
  }, (err) => {
3056
3070
  utils.flag(this, "object", err);
3057
3071
  return result.call(this, ...args);
package/dist/worker.js CHANGED
@@ -1,6 +1,6 @@
1
- import { d as dirname, b as basename, k as resolve, p as mergeSlashes, q as join, s as slash, m as toFilePath } from './index-9fdde2e8.js';
1
+ import { d as dirname, b as basename, k as resolve, p as mergeSlashes, q as join, s as slash, m as toFilePath } from './index-f0488a5d.js';
2
2
  import { c as createBirpc } from './index-e909c175.js';
3
- import { c as distDir } from './constants-8b3a9b31.js';
3
+ import { c as distDir } from './constants-2cd49e0a.js';
4
4
  import { builtinModules, createRequire } from 'module';
5
5
  import { pathToFileURL, fileURLToPath } from 'url';
6
6
  import vm from 'vm';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.126",
3
+ "version": "0.0.127",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -91,7 +91,7 @@
91
91
  "strip-ansi": "^7.0.1",
92
92
  "typescript": "^4.5.4",
93
93
  "ws": "^8.4.0",
94
- "@vitest/ui": "0.0.126"
94
+ "@vitest/ui": "0.0.127"
95
95
  },
96
96
  "peerDependencies": {
97
97
  "c8": "*",