vitest 0.0.126 → 0.0.130
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 +4 -4
- package/dist/{constants-8b3a9b31.js → constants-5b9c0d41.js} +1 -1
- package/dist/entry.js +26 -16
- package/dist/{global-eb23b22e.js → global-4d67a585.js} +3 -3
- package/dist/{index-4b6e78b4.js → index-6f5d03b2.js} +1 -1
- package/dist/{index-e04b9e4c.js → index-bc2183ca.js} +91 -47
- package/dist/index.d.ts +120 -20
- package/dist/index.js +2 -2
- package/dist/node.d.ts +119 -20
- package/dist/node.js +2 -2
- package/dist/{setup-b0d2ca33.js → setup-a6f22d64.js} +1 -1
- package/dist/{vi-5ff3926d.js → vi-8ac1afa2.js} +16 -2
- package/dist/worker.js +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { m as mergeStream, g as getStream, c as crossSpawn } from './index-6e709
|
|
|
8
8
|
import require$$0, { constants } from 'os';
|
|
9
9
|
import { s as signalExit } from './index-648e7ab2.js';
|
|
10
10
|
import { e as ensurePackageInstalled } from './index-9fdde2e8.js';
|
|
11
|
-
import { c as createVitest } from './index-
|
|
11
|
+
import { c as createVitest } from './index-bc2183ca.js';
|
|
12
12
|
import './_commonjsHelpers-c9e3b764.js';
|
|
13
13
|
import 'fs';
|
|
14
14
|
import 'stream';
|
|
@@ -18,7 +18,7 @@ import 'url';
|
|
|
18
18
|
import 'tty';
|
|
19
19
|
import 'local-pkg';
|
|
20
20
|
import 'vite';
|
|
21
|
-
import './constants-
|
|
21
|
+
import './constants-5b9c0d41.js';
|
|
22
22
|
import './magic-string.es-94000aea.js';
|
|
23
23
|
import 'perf_hooks';
|
|
24
24
|
import './diff-3adb959a.js';
|
|
@@ -1700,11 +1700,11 @@ function execa(file, args, options) {
|
|
|
1700
1700
|
return mergePromise(spawned, handlePromiseOnce);
|
|
1701
1701
|
}
|
|
1702
1702
|
|
|
1703
|
-
var version = "0.0.
|
|
1703
|
+
var version = "0.0.130";
|
|
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", "
|
|
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);
|
|
@@ -30,4 +30,4 @@ const globalApis = [
|
|
|
30
30
|
"afterEach"
|
|
31
31
|
];
|
|
32
32
|
|
|
33
|
-
export { API_PATH as A,
|
|
33
|
+
export { API_PATH as A, defaultInclude as a, defaultExclude as b, distDir as c, defaultPort as d, configFiles as e, globalApis as g };
|
package/dist/entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-8ac1afa2.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
@@ -1225,7 +1225,7 @@ async function setupGlobalEnv(config) {
|
|
|
1225
1225
|
setupConsoleLogSpy();
|
|
1226
1226
|
await setupChai();
|
|
1227
1227
|
if (config.global)
|
|
1228
|
-
(await import('./global-
|
|
1228
|
+
(await import('./global-4d67a585.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
|
-
|
|
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
|
-
|
|
1294
|
-
|
|
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.
|
|
1298
|
-
|
|
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)
|
|
@@ -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.
|
|
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.
|
|
1433
|
-
const p = rpc().onTaskUpdate(packs);
|
|
1434
|
-
packs.
|
|
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-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-5b9c0d41.js';
|
|
2
|
+
import { i as index } from './index-6f5d03b2.js';
|
|
3
3
|
import 'url';
|
|
4
4
|
import './index-9fdde2e8.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './vi-
|
|
8
|
+
import './vi-8ac1afa2.js';
|
|
9
9
|
import './jest-mock-30625866.js';
|
|
10
10
|
import 'chai';
|
|
11
11
|
import 'tinyspy';
|
|
@@ -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-
|
|
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-8ac1afa2.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
|
|
|
@@ -7,7 +7,7 @@ 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
|
|
10
|
+
import { d as defaultPort, a as defaultInclude, b as defaultExclude, c as distDir, e as configFiles } from './constants-5b9c0d41.js';
|
|
11
11
|
import MagicString from './magic-string.es-94000aea.js';
|
|
12
12
|
import { performance } from 'perf_hooks';
|
|
13
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';
|
|
@@ -7823,25 +7823,25 @@ const ReportersMap = {
|
|
|
7823
7823
|
dot: DotReporter
|
|
7824
7824
|
};
|
|
7825
7825
|
|
|
7826
|
-
var __defProp$
|
|
7827
|
-
var __defProps$
|
|
7828
|
-
var __getOwnPropDescs$
|
|
7829
|
-
var __getOwnPropSymbols$
|
|
7830
|
-
var __hasOwnProp$
|
|
7831
|
-
var __propIsEnum$
|
|
7832
|
-
var __defNormalProp$
|
|
7833
|
-
var __spreadValues$
|
|
7826
|
+
var __defProp$2 = Object.defineProperty;
|
|
7827
|
+
var __defProps$2 = Object.defineProperties;
|
|
7828
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
7829
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
7830
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
7831
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
7832
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7833
|
+
var __spreadValues$2 = (a, b) => {
|
|
7834
7834
|
for (var prop in b || (b = {}))
|
|
7835
|
-
if (__hasOwnProp$
|
|
7836
|
-
__defNormalProp$
|
|
7837
|
-
if (__getOwnPropSymbols$
|
|
7838
|
-
for (var prop of __getOwnPropSymbols$
|
|
7839
|
-
if (__propIsEnum$
|
|
7840
|
-
__defNormalProp$
|
|
7835
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
7836
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
7837
|
+
if (__getOwnPropSymbols$2)
|
|
7838
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
7839
|
+
if (__propIsEnum$2.call(b, prop))
|
|
7840
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
7841
7841
|
}
|
|
7842
7842
|
return a;
|
|
7843
7843
|
};
|
|
7844
|
-
var __spreadProps$
|
|
7844
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
7845
7845
|
const defaultExcludes = [
|
|
7846
7846
|
"coverage/**",
|
|
7847
7847
|
"packages/*/test{,s}/**",
|
|
@@ -7854,7 +7854,7 @@ const defaultExcludes = [
|
|
|
7854
7854
|
"**/.{eslint,mocha}rc.{js,cjs}"
|
|
7855
7855
|
];
|
|
7856
7856
|
function resolveC8Options(options, root) {
|
|
7857
|
-
const resolved = __spreadValues$
|
|
7857
|
+
const resolved = __spreadValues$2({
|
|
7858
7858
|
enabled: false,
|
|
7859
7859
|
clean: true,
|
|
7860
7860
|
cleanOnRerun: false,
|
|
@@ -7883,7 +7883,7 @@ async function reportCoverage(ctx) {
|
|
|
7883
7883
|
const url = pathToFileURL(file).href;
|
|
7884
7884
|
const sources = map.sources.length ? map.sources.map((i) => pathToFileURL(i).href) : [url];
|
|
7885
7885
|
report.sourceMapCache[url] = {
|
|
7886
|
-
data: __spreadProps$
|
|
7886
|
+
data: __spreadProps$2(__spreadValues$2({}, map), { sources })
|
|
7887
7887
|
};
|
|
7888
7888
|
});
|
|
7889
7889
|
await report.run();
|
|
@@ -7924,30 +7924,56 @@ class StateManager {
|
|
|
7924
7924
|
}
|
|
7925
7925
|
}
|
|
7926
7926
|
|
|
7927
|
-
var __defProp = Object.defineProperty;
|
|
7928
|
-
var __defProps = Object.defineProperties;
|
|
7929
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7930
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7931
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7932
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7933
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7934
|
-
var __spreadValues = (a, b) => {
|
|
7927
|
+
var __defProp$1 = Object.defineProperty;
|
|
7928
|
+
var __defProps$1 = Object.defineProperties;
|
|
7929
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
7930
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
7931
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
7932
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
7933
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7934
|
+
var __spreadValues$1 = (a, b) => {
|
|
7935
7935
|
for (var prop in b || (b = {}))
|
|
7936
|
-
if (__hasOwnProp.call(b, prop))
|
|
7937
|
-
__defNormalProp(a, prop, b[prop]);
|
|
7938
|
-
if (__getOwnPropSymbols)
|
|
7939
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
7940
|
-
if (__propIsEnum.call(b, prop))
|
|
7941
|
-
__defNormalProp(a, prop, b[prop]);
|
|
7936
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
7937
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
7938
|
+
if (__getOwnPropSymbols$1)
|
|
7939
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
7940
|
+
if (__propIsEnum$1.call(b, prop))
|
|
7941
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
7942
7942
|
}
|
|
7943
7943
|
return a;
|
|
7944
7944
|
};
|
|
7945
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7945
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
7946
|
+
function resolveApiConfig(options, viteOverrides) {
|
|
7947
|
+
let api;
|
|
7948
|
+
if (options.api === true)
|
|
7949
|
+
api = { port: defaultPort };
|
|
7950
|
+
else if (typeof options.api === "number")
|
|
7951
|
+
api = { port: options.api };
|
|
7952
|
+
if (typeof options.api === "object") {
|
|
7953
|
+
if (api) {
|
|
7954
|
+
if (options.api.port)
|
|
7955
|
+
api.port = options.api.port;
|
|
7956
|
+
if (options.api.strictPort)
|
|
7957
|
+
api.strictPort = options.api.strictPort;
|
|
7958
|
+
if (options.api.host)
|
|
7959
|
+
api.host = options.api.host;
|
|
7960
|
+
} else {
|
|
7961
|
+
api = __spreadValues$1({}, options.api);
|
|
7962
|
+
}
|
|
7963
|
+
}
|
|
7964
|
+
if (api) {
|
|
7965
|
+
if (!api.port)
|
|
7966
|
+
api.port = defaultPort;
|
|
7967
|
+
if (viteOverrides)
|
|
7968
|
+
viteOverrides.server = Object.assign(viteOverrides.server || {}, api);
|
|
7969
|
+
}
|
|
7970
|
+
return api;
|
|
7971
|
+
}
|
|
7946
7972
|
function resolveConfig(options, viteConfig) {
|
|
7947
7973
|
var _a, _b, _c, _d;
|
|
7948
7974
|
if (options.dom)
|
|
7949
7975
|
options.environment = "happy-dom";
|
|
7950
|
-
const resolved = __spreadProps(__spreadValues({}, deepMerge(options, viteConfig.test)), {
|
|
7976
|
+
const resolved = __spreadProps$1(__spreadValues$1({}, deepMerge(options, viteConfig.test)), {
|
|
7951
7977
|
root: viteConfig.root
|
|
7952
7978
|
});
|
|
7953
7979
|
resolved.coverage = resolveC8Options(resolved.coverage, resolved.root);
|
|
@@ -7977,8 +8003,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
7977
8003
|
if (process.env.VITEST_MIN_THREADS)
|
|
7978
8004
|
resolved.minThreads = parseInt(process.env.VITEST_MIN_THREADS);
|
|
7979
8005
|
resolved.setupFiles = Array.from(resolved.setupFiles || []).map((i) => resolve(resolved.root, i));
|
|
7980
|
-
|
|
7981
|
-
resolved.api = defaultPort;
|
|
8006
|
+
resolved.api = resolveApiConfig(options);
|
|
7982
8007
|
if (options.related)
|
|
7983
8008
|
resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
|
|
7984
8009
|
return resolved;
|
|
@@ -8136,6 +8161,25 @@ function createChannel(ctx) {
|
|
|
8136
8161
|
return { workerPort, port };
|
|
8137
8162
|
}
|
|
8138
8163
|
|
|
8164
|
+
var __defProp = Object.defineProperty;
|
|
8165
|
+
var __defProps = Object.defineProperties;
|
|
8166
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8167
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8168
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8169
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8170
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8171
|
+
var __spreadValues = (a, b) => {
|
|
8172
|
+
for (var prop in b || (b = {}))
|
|
8173
|
+
if (__hasOwnProp.call(b, prop))
|
|
8174
|
+
__defNormalProp(a, prop, b[prop]);
|
|
8175
|
+
if (__getOwnPropSymbols)
|
|
8176
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
8177
|
+
if (__propIsEnum.call(b, prop))
|
|
8178
|
+
__defNormalProp(a, prop, b[prop]);
|
|
8179
|
+
}
|
|
8180
|
+
return a;
|
|
8181
|
+
};
|
|
8182
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
8139
8183
|
const WATCHER_DEBOUNCE = 100;
|
|
8140
8184
|
class Vitest {
|
|
8141
8185
|
constructor() {
|
|
@@ -8186,7 +8230,7 @@ class Vitest {
|
|
|
8186
8230
|
await cleanCoverage(resolved.coverage, resolved.coverage.clean);
|
|
8187
8231
|
}
|
|
8188
8232
|
async start(filters) {
|
|
8189
|
-
this.report("onInit", this);
|
|
8233
|
+
await this.report("onInit", this);
|
|
8190
8234
|
const files = await this.filterTestsBySource(await this.globTestFiles(filters));
|
|
8191
8235
|
if (!files.length) {
|
|
8192
8236
|
if (this.config.passWithNoTests)
|
|
@@ -8376,6 +8420,7 @@ class Vitest {
|
|
|
8376
8420
|
}
|
|
8377
8421
|
}
|
|
8378
8422
|
async function createVitest(options, viteOverrides = {}) {
|
|
8423
|
+
var _a;
|
|
8379
8424
|
const ctx = new Vitest();
|
|
8380
8425
|
const root = resolve(options.root || process.cwd());
|
|
8381
8426
|
const configPath = options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
@@ -8386,6 +8431,7 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8386
8431
|
await ensurePackageInstalled("@vitest/ui");
|
|
8387
8432
|
return (await import('@vitest/ui')).default();
|
|
8388
8433
|
}
|
|
8434
|
+
options.api = resolveApiConfig(options, viteOverrides);
|
|
8389
8435
|
const config = {
|
|
8390
8436
|
root,
|
|
8391
8437
|
logLevel: "error",
|
|
@@ -8394,35 +8440,33 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8394
8440
|
plugins: [
|
|
8395
8441
|
{
|
|
8396
8442
|
name: "vitest",
|
|
8443
|
+
enforce: "pre",
|
|
8397
8444
|
async configureServer(server2) {
|
|
8398
8445
|
if (haveStarted)
|
|
8399
8446
|
await ctx.report("onServerRestart");
|
|
8400
8447
|
await ctx.setServer(options, server2);
|
|
8401
8448
|
haveStarted = true;
|
|
8402
8449
|
if (options.api)
|
|
8403
|
-
(await import('./setup-
|
|
8450
|
+
(await import('./setup-a6f22d64.js')).setup(ctx);
|
|
8451
|
+
if (!options.watch)
|
|
8452
|
+
await server2.watcher.close();
|
|
8404
8453
|
}
|
|
8405
8454
|
},
|
|
8406
8455
|
MocksPlugin(),
|
|
8407
8456
|
await UIPlugin()
|
|
8408
8457
|
],
|
|
8409
|
-
server: {
|
|
8458
|
+
server: __spreadProps(__spreadValues({}, options.api), {
|
|
8410
8459
|
open: options.open ? "/__vitest__/" : void 0,
|
|
8411
|
-
strictPort: true,
|
|
8412
8460
|
preTransformRequests: false
|
|
8413
|
-
},
|
|
8461
|
+
}),
|
|
8414
8462
|
build: {
|
|
8415
8463
|
sourcemap: true
|
|
8416
8464
|
}
|
|
8417
8465
|
};
|
|
8418
8466
|
const server = await createServer(mergeConfig(config, viteOverrides));
|
|
8419
8467
|
await server.pluginContainer.buildStart({});
|
|
8420
|
-
if (options.api
|
|
8421
|
-
|
|
8422
|
-
if (options.open && typeof options.api !== "number")
|
|
8423
|
-
options.api = defaultPort;
|
|
8424
|
-
if (typeof options.api === "number")
|
|
8425
|
-
await server.listen(options.api);
|
|
8468
|
+
if ((_a = options.api) == null ? void 0 : _a.port)
|
|
8469
|
+
await server.listen();
|
|
8426
8470
|
return ctx;
|
|
8427
8471
|
}
|
|
8428
8472
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Formatter } from 'picocolors/types';
|
|
3
|
-
import { ViteDevServer } from 'vite';
|
|
4
|
-
import { RawSourceMap } from 'source-map-js';
|
|
1
|
+
import { ViteDevServer, CommonServerOptions } from 'vite';
|
|
5
2
|
import { MessagePort } from 'worker_threads';
|
|
6
3
|
import { SpyImpl } from 'tinyspy';
|
|
7
4
|
export { Spy, SpyFn } from 'tinyspy';
|
|
8
5
|
export { assert, default as chai, should } from 'chai';
|
|
9
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
declare type Colors = {
|
|
14
|
+
comment: {
|
|
15
|
+
close: string;
|
|
16
|
+
open: string;
|
|
17
|
+
};
|
|
18
|
+
content: {
|
|
19
|
+
close: string;
|
|
20
|
+
open: string;
|
|
21
|
+
};
|
|
22
|
+
prop: {
|
|
23
|
+
close: string;
|
|
24
|
+
open: string;
|
|
25
|
+
};
|
|
26
|
+
tag: {
|
|
27
|
+
close: string;
|
|
28
|
+
open: string;
|
|
29
|
+
};
|
|
30
|
+
value: {
|
|
31
|
+
close: string;
|
|
32
|
+
open: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
declare type Indent = (arg0: string) => string;
|
|
36
|
+
declare type Refs = Array<unknown>;
|
|
37
|
+
declare type Print = (arg0: unknown) => string;
|
|
38
|
+
declare type ThemeReceived = {
|
|
39
|
+
comment?: string;
|
|
40
|
+
content?: string;
|
|
41
|
+
prop?: string;
|
|
42
|
+
tag?: string;
|
|
43
|
+
value?: string;
|
|
44
|
+
};
|
|
45
|
+
declare type CompareKeys = ((a: string, b: string) => number) | undefined;
|
|
46
|
+
interface PrettyFormatOptions {
|
|
47
|
+
callToJSON?: boolean;
|
|
48
|
+
compareKeys?: CompareKeys;
|
|
49
|
+
escapeRegex?: boolean;
|
|
50
|
+
escapeString?: boolean;
|
|
51
|
+
highlight?: boolean;
|
|
52
|
+
indent?: number;
|
|
53
|
+
maxDepth?: number;
|
|
54
|
+
min?: boolean;
|
|
55
|
+
plugins?: Plugins;
|
|
56
|
+
printBasicPrototype?: boolean;
|
|
57
|
+
printFunctionName?: boolean;
|
|
58
|
+
theme?: ThemeReceived;
|
|
59
|
+
}
|
|
60
|
+
declare type OptionsReceived = PrettyFormatOptions;
|
|
61
|
+
declare type Config = {
|
|
62
|
+
callToJSON: boolean;
|
|
63
|
+
compareKeys: CompareKeys;
|
|
64
|
+
colors: Colors;
|
|
65
|
+
escapeRegex: boolean;
|
|
66
|
+
escapeString: boolean;
|
|
67
|
+
indent: string;
|
|
68
|
+
maxDepth: number;
|
|
69
|
+
min: boolean;
|
|
70
|
+
plugins: Plugins;
|
|
71
|
+
printBasicPrototype: boolean;
|
|
72
|
+
printFunctionName: boolean;
|
|
73
|
+
spacingInner: string;
|
|
74
|
+
spacingOuter: string;
|
|
75
|
+
};
|
|
76
|
+
declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
|
77
|
+
declare type Test$1 = (arg0: any) => boolean;
|
|
78
|
+
declare type NewPlugin = {
|
|
79
|
+
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
80
|
+
test: Test$1;
|
|
81
|
+
};
|
|
82
|
+
declare type PluginOptions = {
|
|
83
|
+
edgeSpacing: string;
|
|
84
|
+
min: boolean;
|
|
85
|
+
spacing: string;
|
|
86
|
+
};
|
|
87
|
+
declare type OldPlugin = {
|
|
88
|
+
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
|
|
89
|
+
test: Test$1;
|
|
90
|
+
};
|
|
91
|
+
declare type Plugin = NewPlugin | OldPlugin;
|
|
92
|
+
declare type Plugins = Array<Plugin>;
|
|
93
|
+
|
|
94
|
+
declare type Formatter = (input: string | number | null | undefined) => string;
|
|
95
|
+
|
|
10
96
|
declare const EXPECTED_COLOR: Formatter;
|
|
11
97
|
declare const RECEIVED_COLOR: Formatter;
|
|
12
98
|
declare const INVERTED_COLOR: Formatter;
|
|
@@ -162,6 +248,19 @@ declare class StringMatching extends AsymmetricMatcher<RegExp> {
|
|
|
162
248
|
getExpectedType(): string;
|
|
163
249
|
}
|
|
164
250
|
|
|
251
|
+
interface StartOfSourceMap {
|
|
252
|
+
file?: string;
|
|
253
|
+
sourceRoot?: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface RawSourceMap extends StartOfSourceMap {
|
|
257
|
+
version: string;
|
|
258
|
+
sources: string[];
|
|
259
|
+
names: string[];
|
|
260
|
+
sourcesContent?: string[];
|
|
261
|
+
mappings: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
165
264
|
declare class SnapshotManager {
|
|
166
265
|
config: ResolvedConfig;
|
|
167
266
|
summary: SnapshotSummary;
|
|
@@ -511,6 +610,7 @@ interface SnapshotSummary {
|
|
|
511
610
|
}
|
|
512
611
|
|
|
513
612
|
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
|
|
613
|
+
declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
|
|
514
614
|
interface InlineConfig {
|
|
515
615
|
/**
|
|
516
616
|
* Include globs for test files
|
|
@@ -647,24 +747,10 @@ interface InlineConfig {
|
|
|
647
747
|
* Coverage options
|
|
648
748
|
*/
|
|
649
749
|
coverage?: C8Options;
|
|
650
|
-
/**
|
|
651
|
-
* Open Vitest UI
|
|
652
|
-
* @internal WIP
|
|
653
|
-
*/
|
|
654
|
-
open?: boolean;
|
|
655
750
|
/**
|
|
656
751
|
* run test names with the specified pattern
|
|
657
752
|
*/
|
|
658
753
|
testNamePattern?: string | RegExp;
|
|
659
|
-
/**
|
|
660
|
-
* Listen to port and serve API
|
|
661
|
-
*
|
|
662
|
-
* When set to true, the default port is 55555
|
|
663
|
-
*
|
|
664
|
-
* @internal WIP
|
|
665
|
-
* @default false
|
|
666
|
-
*/
|
|
667
|
-
api?: boolean | number;
|
|
668
754
|
/**
|
|
669
755
|
* Will call `.mockClear()` on all spies before each test
|
|
670
756
|
* @default false
|
|
@@ -680,6 +766,19 @@ interface InlineConfig {
|
|
|
680
766
|
* @default false
|
|
681
767
|
*/
|
|
682
768
|
restoreMocks?: boolean;
|
|
769
|
+
/**
|
|
770
|
+
* Serve API options.
|
|
771
|
+
*
|
|
772
|
+
* When set to true, the default port is 51204.
|
|
773
|
+
*
|
|
774
|
+
* @default false
|
|
775
|
+
*/
|
|
776
|
+
api?: boolean | number | ApiConfig;
|
|
777
|
+
/**
|
|
778
|
+
* Open Vitest UI
|
|
779
|
+
* @internal WIP
|
|
780
|
+
*/
|
|
781
|
+
open?: boolean;
|
|
683
782
|
}
|
|
684
783
|
interface UserConfig extends InlineConfig {
|
|
685
784
|
/**
|
|
@@ -709,7 +808,7 @@ interface UserConfig extends InlineConfig {
|
|
|
709
808
|
*/
|
|
710
809
|
related?: string[] | string;
|
|
711
810
|
}
|
|
712
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related'> {
|
|
811
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api'> {
|
|
713
812
|
config?: string;
|
|
714
813
|
filters?: string[];
|
|
715
814
|
testNamePattern?: RegExp;
|
|
@@ -720,6 +819,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
720
819
|
interpretDefault: boolean;
|
|
721
820
|
coverage: ResolvedC8Options;
|
|
722
821
|
snapshotOptions: SnapshotStateOptions;
|
|
822
|
+
api?: ApiConfig;
|
|
723
823
|
}
|
|
724
824
|
|
|
725
825
|
interface WorkerContext {
|
|
@@ -1012,4 +1112,4 @@ declare global {
|
|
|
1012
1112
|
}
|
|
1013
1113
|
}
|
|
1014
1114
|
|
|
1015
|
-
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ConstructorArgumentsOf, DoneCallback, EnhancedSpy, Environment, EnvironmentReturn, ErrorWithDiff, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, isMockFunction, it, spies, spyOn, suite, test, vi, vitest };
|
|
1115
|
+
export { ApiConfig, ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ConstructorArgumentsOf, DoneCallback, EnhancedSpy, Environment, EnvironmentReturn, ErrorWithDiff, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, isMockFunction, it, spies, spyOn, suite, test, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-
|
|
1
|
+
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-8ac1afa2.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-6f5d03b2.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
5
|
import './index-9fdde2e8.js';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { CommonServerOptions, ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
|
|
2
|
+
|
|
3
|
+
interface StartOfSourceMap {
|
|
4
|
+
file?: string;
|
|
5
|
+
sourceRoot?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface RawSourceMap extends StartOfSourceMap {
|
|
9
|
+
version: string;
|
|
10
|
+
sources: string[];
|
|
11
|
+
names: string[];
|
|
12
|
+
sourcesContent?: string[];
|
|
13
|
+
mappings: string;
|
|
14
|
+
}
|
|
4
15
|
|
|
5
16
|
declare abstract class BaseReporter implements Reporter {
|
|
6
17
|
start: number;
|
|
@@ -170,13 +181,13 @@ interface File extends Suite {
|
|
|
170
181
|
filepath: string;
|
|
171
182
|
collectDuration?: number;
|
|
172
183
|
}
|
|
173
|
-
interface Test extends TaskBase {
|
|
184
|
+
interface Test$1 extends TaskBase {
|
|
174
185
|
type: 'test';
|
|
175
186
|
suite: Suite;
|
|
176
187
|
result?: TaskResult;
|
|
177
188
|
fails?: boolean;
|
|
178
189
|
}
|
|
179
|
-
declare type Task = Test | Suite | File;
|
|
190
|
+
declare type Task = Test$1 | Suite | File;
|
|
180
191
|
|
|
181
192
|
interface Reporter {
|
|
182
193
|
onInit?(ctx: Vitest): void;
|
|
@@ -189,6 +200,93 @@ interface Reporter {
|
|
|
189
200
|
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
190
201
|
}
|
|
191
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
205
|
+
*
|
|
206
|
+
* This source code is licensed under the MIT license found in the
|
|
207
|
+
* LICENSE file in the root directory of this source tree.
|
|
208
|
+
*/
|
|
209
|
+
declare type Colors = {
|
|
210
|
+
comment: {
|
|
211
|
+
close: string;
|
|
212
|
+
open: string;
|
|
213
|
+
};
|
|
214
|
+
content: {
|
|
215
|
+
close: string;
|
|
216
|
+
open: string;
|
|
217
|
+
};
|
|
218
|
+
prop: {
|
|
219
|
+
close: string;
|
|
220
|
+
open: string;
|
|
221
|
+
};
|
|
222
|
+
tag: {
|
|
223
|
+
close: string;
|
|
224
|
+
open: string;
|
|
225
|
+
};
|
|
226
|
+
value: {
|
|
227
|
+
close: string;
|
|
228
|
+
open: string;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
declare type Indent = (arg0: string) => string;
|
|
232
|
+
declare type Refs = Array<unknown>;
|
|
233
|
+
declare type Print = (arg0: unknown) => string;
|
|
234
|
+
declare type ThemeReceived = {
|
|
235
|
+
comment?: string;
|
|
236
|
+
content?: string;
|
|
237
|
+
prop?: string;
|
|
238
|
+
tag?: string;
|
|
239
|
+
value?: string;
|
|
240
|
+
};
|
|
241
|
+
declare type CompareKeys = ((a: string, b: string) => number) | undefined;
|
|
242
|
+
interface PrettyFormatOptions {
|
|
243
|
+
callToJSON?: boolean;
|
|
244
|
+
compareKeys?: CompareKeys;
|
|
245
|
+
escapeRegex?: boolean;
|
|
246
|
+
escapeString?: boolean;
|
|
247
|
+
highlight?: boolean;
|
|
248
|
+
indent?: number;
|
|
249
|
+
maxDepth?: number;
|
|
250
|
+
min?: boolean;
|
|
251
|
+
plugins?: Plugins;
|
|
252
|
+
printBasicPrototype?: boolean;
|
|
253
|
+
printFunctionName?: boolean;
|
|
254
|
+
theme?: ThemeReceived;
|
|
255
|
+
}
|
|
256
|
+
declare type OptionsReceived = PrettyFormatOptions;
|
|
257
|
+
declare type Config = {
|
|
258
|
+
callToJSON: boolean;
|
|
259
|
+
compareKeys: CompareKeys;
|
|
260
|
+
colors: Colors;
|
|
261
|
+
escapeRegex: boolean;
|
|
262
|
+
escapeString: boolean;
|
|
263
|
+
indent: string;
|
|
264
|
+
maxDepth: number;
|
|
265
|
+
min: boolean;
|
|
266
|
+
plugins: Plugins;
|
|
267
|
+
printBasicPrototype: boolean;
|
|
268
|
+
printFunctionName: boolean;
|
|
269
|
+
spacingInner: string;
|
|
270
|
+
spacingOuter: string;
|
|
271
|
+
};
|
|
272
|
+
declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
|
273
|
+
declare type Test = (arg0: any) => boolean;
|
|
274
|
+
declare type NewPlugin = {
|
|
275
|
+
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
276
|
+
test: Test;
|
|
277
|
+
};
|
|
278
|
+
declare type PluginOptions = {
|
|
279
|
+
edgeSpacing: string;
|
|
280
|
+
min: boolean;
|
|
281
|
+
spacing: string;
|
|
282
|
+
};
|
|
283
|
+
declare type OldPlugin = {
|
|
284
|
+
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
|
|
285
|
+
test: Test;
|
|
286
|
+
};
|
|
287
|
+
declare type Plugin = NewPlugin | OldPlugin;
|
|
288
|
+
declare type Plugins = Array<Plugin>;
|
|
289
|
+
|
|
192
290
|
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
193
291
|
declare type SnapshotStateOptions = {
|
|
194
292
|
updateSnapshot: SnapshotUpdateState;
|
|
@@ -227,6 +325,7 @@ interface SnapshotSummary {
|
|
|
227
325
|
}
|
|
228
326
|
|
|
229
327
|
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
|
|
328
|
+
declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
|
|
230
329
|
interface InlineConfig {
|
|
231
330
|
/**
|
|
232
331
|
* Include globs for test files
|
|
@@ -363,24 +462,10 @@ interface InlineConfig {
|
|
|
363
462
|
* Coverage options
|
|
364
463
|
*/
|
|
365
464
|
coverage?: C8Options;
|
|
366
|
-
/**
|
|
367
|
-
* Open Vitest UI
|
|
368
|
-
* @internal WIP
|
|
369
|
-
*/
|
|
370
|
-
open?: boolean;
|
|
371
465
|
/**
|
|
372
466
|
* run test names with the specified pattern
|
|
373
467
|
*/
|
|
374
468
|
testNamePattern?: string | RegExp;
|
|
375
|
-
/**
|
|
376
|
-
* Listen to port and serve API
|
|
377
|
-
*
|
|
378
|
-
* When set to true, the default port is 55555
|
|
379
|
-
*
|
|
380
|
-
* @internal WIP
|
|
381
|
-
* @default false
|
|
382
|
-
*/
|
|
383
|
-
api?: boolean | number;
|
|
384
469
|
/**
|
|
385
470
|
* Will call `.mockClear()` on all spies before each test
|
|
386
471
|
* @default false
|
|
@@ -396,6 +481,19 @@ interface InlineConfig {
|
|
|
396
481
|
* @default false
|
|
397
482
|
*/
|
|
398
483
|
restoreMocks?: boolean;
|
|
484
|
+
/**
|
|
485
|
+
* Serve API options.
|
|
486
|
+
*
|
|
487
|
+
* When set to true, the default port is 51204.
|
|
488
|
+
*
|
|
489
|
+
* @default false
|
|
490
|
+
*/
|
|
491
|
+
api?: boolean | number | ApiConfig;
|
|
492
|
+
/**
|
|
493
|
+
* Open Vitest UI
|
|
494
|
+
* @internal WIP
|
|
495
|
+
*/
|
|
496
|
+
open?: boolean;
|
|
399
497
|
}
|
|
400
498
|
interface UserConfig extends InlineConfig {
|
|
401
499
|
/**
|
|
@@ -425,7 +523,7 @@ interface UserConfig extends InlineConfig {
|
|
|
425
523
|
*/
|
|
426
524
|
related?: string[] | string;
|
|
427
525
|
}
|
|
428
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related'> {
|
|
526
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api'> {
|
|
429
527
|
config?: string;
|
|
430
528
|
filters?: string[];
|
|
431
529
|
testNamePattern?: RegExp;
|
|
@@ -436,6 +534,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
436
534
|
interpretDefault: boolean;
|
|
437
535
|
coverage: ResolvedC8Options;
|
|
438
536
|
snapshotOptions: SnapshotStateOptions;
|
|
537
|
+
api?: ApiConfig;
|
|
439
538
|
}
|
|
440
539
|
|
|
441
540
|
declare class SnapshotManager {
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
1
|
+
export { c as createVitest } from './index-bc2183ca.js';
|
|
2
2
|
import 'fs';
|
|
3
3
|
import './index-9fdde2e8.js';
|
|
4
4
|
import 'url';
|
|
@@ -11,7 +11,7 @@ import 'os';
|
|
|
11
11
|
import 'util';
|
|
12
12
|
import 'stream';
|
|
13
13
|
import 'events';
|
|
14
|
-
import './constants-
|
|
14
|
+
import './constants-5b9c0d41.js';
|
|
15
15
|
import './magic-string.es-94000aea.js';
|
|
16
16
|
import 'perf_hooks';
|
|
17
17
|
import './diff-3adb959a.js';
|
|
@@ -9,7 +9,7 @@ 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-
|
|
12
|
+
import { A as API_PATH } from './constants-5b9c0d41.js';
|
|
13
13
|
import { s as shouldExternalize } from './externalize-2f63779d.js';
|
|
14
14
|
import { o as interpretSourcePos, n as parseStacktrace } from './diff-3adb959a.js';
|
|
15
15
|
import './index-9fdde2e8.js';
|
|
@@ -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
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';
|
|
2
2
|
import { c as createBirpc } from './index-e909c175.js';
|
|
3
|
-
import { c as distDir } from './constants-
|
|
3
|
+
import { c as distDir } from './constants-5b9c0d41.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.
|
|
3
|
+
"version": "0.0.130",
|
|
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.
|
|
94
|
+
"@vitest/ui": "0.0.130"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"c8": "*",
|