vitest 0.0.115 → 0.0.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +27 -28
- package/dist/cli.js +30 -11
- package/dist/{constants-5968a78c.js → constants-22bbd600.js} +1 -1
- package/dist/{diff-67678e1f.js → diff-a295cb37.js} +1 -1
- package/dist/entry.js +95 -16
- package/dist/{global-bc40af7c.js → global-8f03a13e.js} +4 -4
- package/dist/{index-7c024e16.js → index-090545ef.js} +3 -20
- package/dist/{index-7f57c252.js → index-31a38185.js} +1 -1
- package/dist/{index-b4f86684.js → index-478354a1.js} +67 -58
- package/dist/index.d.ts +33 -19
- package/dist/index.js +3 -3
- package/dist/node.d.ts +22 -17
- package/dist/node.js +4 -4
- package/dist/setup-638014f2.js +4318 -0
- package/dist/utils.js +1 -1
- package/dist/{vi-2115c609.js → vi-092f86e3.js} +30 -16
- package/dist/worker.js +17 -8
- package/package.json +5 -6
- package/dist/middleware-647438b9.js +0 -81
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-
|
|
1
|
+
import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-090545ef.js';
|
|
2
2
|
import { createServer, mergeConfig } from 'vite';
|
|
3
3
|
import path$a from 'path';
|
|
4
4
|
import process$1 from 'process';
|
|
@@ -7,10 +7,10 @@ import require$$0 from 'os';
|
|
|
7
7
|
import require$$0$1 from 'util';
|
|
8
8
|
import require$$0$2 from 'stream';
|
|
9
9
|
import require$$2 from 'events';
|
|
10
|
-
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-
|
|
10
|
+
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-22bbd600.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-
|
|
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-a295cb37.js';
|
|
14
14
|
import { o as onetime, s as signalExit } from './index-648e7ab2.js';
|
|
15
15
|
import { createRequire } from 'module';
|
|
16
16
|
import { pathToFileURL } from 'url';
|
|
@@ -6849,7 +6849,7 @@ const MocksPlugin = () => {
|
|
|
6849
6849
|
|
|
6850
6850
|
const spinnerMap = /* @__PURE__ */ new WeakMap();
|
|
6851
6851
|
const pointer = c.yellow(F_POINTER);
|
|
6852
|
-
const skipped = c.
|
|
6852
|
+
const skipped = c.dim(c.gray(F_DOWN));
|
|
6853
6853
|
function getCols(delta = 0) {
|
|
6854
6854
|
let length = process.stdout.columns;
|
|
6855
6855
|
if (!length || isNaN(length))
|
|
@@ -6988,15 +6988,17 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
|
|
|
6988
6988
|
this.end = performance.now();
|
|
6989
6989
|
await this.reportSummary(files);
|
|
6990
6990
|
}
|
|
6991
|
-
onTaskUpdate(
|
|
6991
|
+
onTaskUpdate(packs) {
|
|
6992
6992
|
var _a, _b, _c;
|
|
6993
6993
|
if (this.isTTY)
|
|
6994
6994
|
return;
|
|
6995
|
-
const
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
6995
|
+
for (const pack of packs) {
|
|
6996
|
+
const task = this.ctx.state.idMap.get(pack[0]);
|
|
6997
|
+
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
6998
|
+
this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
|
|
6999
|
+
if (task.result.state === "fail")
|
|
7000
|
+
this.ctx.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
|
|
7001
|
+
}
|
|
7000
7002
|
}
|
|
7001
7003
|
}
|
|
7002
7004
|
async onWatcherStart() {
|
|
@@ -7015,13 +7017,14 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
|
|
|
7015
7017
|
async onWatcherRerun(files, trigger) {
|
|
7016
7018
|
this.watchFilters = files;
|
|
7017
7019
|
this.ctx.console.clear();
|
|
7018
|
-
this.ctx.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
|
|
7019
|
-
`));
|
|
7020
|
+
this.ctx.log(c.blue("Re-running tests...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
7021
|
+
`) : ""));
|
|
7022
|
+
this.start = performance.now();
|
|
7020
7023
|
}
|
|
7021
7024
|
onUserConsoleLog(log) {
|
|
7022
7025
|
if (this.ctx.config.silent)
|
|
7023
7026
|
return;
|
|
7024
|
-
const task = log.taskId ? this.ctx.state.idMap
|
|
7027
|
+
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
7025
7028
|
this.ctx.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
|
|
7026
7029
|
process[log.type].write(`${log.content}
|
|
7027
7030
|
`);
|
|
@@ -7611,10 +7614,10 @@ function renderTree(tasks, options, level = 0) {
|
|
|
7611
7614
|
for (const task of tasks) {
|
|
7612
7615
|
let suffix = "";
|
|
7613
7616
|
const prefix = ` ${getStateSymbol(task)} `;
|
|
7614
|
-
if (task.mode === "skip" || task.mode === "todo")
|
|
7615
|
-
suffix += ` ${c.dim("[skipped]")}`;
|
|
7616
7617
|
if (task.type === "suite")
|
|
7617
7618
|
suffix += c.dim(` (${getTests(task).length})`);
|
|
7619
|
+
if (task.mode === "skip" || task.mode === "todo")
|
|
7620
|
+
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
7618
7621
|
if ((_a = task.result) == null ? void 0 : _a.end) {
|
|
7619
7622
|
const duration = task.result.end - task.result.start;
|
|
7620
7623
|
if (duration > DURATION_LONG)
|
|
@@ -7683,7 +7686,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
7683
7686
|
super(...arguments);
|
|
7684
7687
|
this.rendererOptions = {};
|
|
7685
7688
|
}
|
|
7686
|
-
|
|
7689
|
+
onCollected() {
|
|
7687
7690
|
if (this.isTTY) {
|
|
7688
7691
|
this.rendererOptions.outputStream = this.ctx.outputStream;
|
|
7689
7692
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
@@ -7704,9 +7707,8 @@ class DefaultReporter extends BaseReporter {
|
|
|
7704
7707
|
}
|
|
7705
7708
|
async stopListRender() {
|
|
7706
7709
|
var _a;
|
|
7707
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
7710
|
+
await ((_a = this.renderer) == null ? void 0 : _a.stop());
|
|
7708
7711
|
this.renderer = void 0;
|
|
7709
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
7710
7712
|
}
|
|
7711
7713
|
async onWatcherRerun(files, trigger) {
|
|
7712
7714
|
await this.stopListRender();
|
|
@@ -7775,7 +7777,7 @@ const createDotRenderer = (_tasks, options) => {
|
|
|
7775
7777
|
};
|
|
7776
7778
|
|
|
7777
7779
|
class DotReporter extends BaseReporter {
|
|
7778
|
-
|
|
7780
|
+
onCollected() {
|
|
7779
7781
|
if (this.isTTY) {
|
|
7780
7782
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
7781
7783
|
if (!this.renderer)
|
|
@@ -7861,7 +7863,7 @@ function resolveC8Options(options, root) {
|
|
|
7861
7863
|
reportsDirectory: "./coverage",
|
|
7862
7864
|
excludeNodeModules: true,
|
|
7863
7865
|
exclude: defaultExcludes,
|
|
7864
|
-
reporter: "text",
|
|
7866
|
+
reporter: ["text", "html"],
|
|
7865
7867
|
allowExternal: false
|
|
7866
7868
|
}, options);
|
|
7867
7869
|
resolved.reporter = toArray(resolved.reporter);
|
|
@@ -7871,27 +7873,19 @@ function resolveC8Options(options, root) {
|
|
|
7871
7873
|
}
|
|
7872
7874
|
async function cleanCoverage(options, clean = true) {
|
|
7873
7875
|
if (clean && existsSync(options.reportsDirectory))
|
|
7874
|
-
await promises.
|
|
7876
|
+
await promises.rm(options.reportsDirectory, { recursive: true, force: true });
|
|
7875
7877
|
if (!existsSync(options.tempDirectory))
|
|
7876
7878
|
await promises.mkdir(options.tempDirectory, { recursive: true });
|
|
7877
7879
|
}
|
|
7878
|
-
async function prepareCoverage(options) {
|
|
7879
|
-
if (options.enabled)
|
|
7880
|
-
return false;
|
|
7881
|
-
await cleanCoverage(options, options.clean);
|
|
7882
|
-
}
|
|
7883
7880
|
const require2 = createRequire(import.meta.url);
|
|
7884
7881
|
async function reportCoverage(ctx) {
|
|
7885
7882
|
const createReport = require2("c8/lib/report");
|
|
7886
7883
|
const report = createReport(ctx.config.coverage);
|
|
7887
7884
|
Array.from(ctx.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/")).forEach(([file, map]) => {
|
|
7888
|
-
if (!existsSync(file))
|
|
7889
|
-
return;
|
|
7890
7885
|
const url = pathToFileURL(file).href;
|
|
7886
|
+
const sources = map.sources.length ? map.sources.map((i) => pathToFileURL(i).href) : [url];
|
|
7891
7887
|
report.sourceMapCache[url] = {
|
|
7892
|
-
data: __spreadProps$1(__spreadValues$1({}, map), {
|
|
7893
|
-
sources: map.sources.map((i) => pathToFileURL(i).href) || [url]
|
|
7894
|
-
})
|
|
7888
|
+
data: __spreadProps$1(__spreadValues$1({}, map), { sources })
|
|
7895
7889
|
};
|
|
7896
7890
|
});
|
|
7897
7891
|
await report.run();
|
|
@@ -7899,25 +7893,25 @@ async function reportCoverage(ctx) {
|
|
|
7899
7893
|
|
|
7900
7894
|
class StateManager {
|
|
7901
7895
|
constructor() {
|
|
7902
|
-
this.filesMap =
|
|
7903
|
-
this.idMap =
|
|
7896
|
+
this.filesMap = /* @__PURE__ */ new Map();
|
|
7897
|
+
this.idMap = /* @__PURE__ */ new Map();
|
|
7904
7898
|
this.taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
7905
7899
|
}
|
|
7906
7900
|
getFiles(keys) {
|
|
7907
7901
|
if (keys)
|
|
7908
|
-
return keys.map((key) => this.filesMap
|
|
7909
|
-
return
|
|
7902
|
+
return keys.map((key) => this.filesMap.get(key));
|
|
7903
|
+
return Array.from(this.filesMap.values());
|
|
7910
7904
|
}
|
|
7911
|
-
collectFiles(files) {
|
|
7905
|
+
collectFiles(files = []) {
|
|
7912
7906
|
files.forEach((file) => {
|
|
7913
|
-
this.filesMap
|
|
7907
|
+
this.filesMap.set(file.filepath, file);
|
|
7914
7908
|
this.updateId(file);
|
|
7915
7909
|
});
|
|
7916
7910
|
}
|
|
7917
7911
|
updateId(task) {
|
|
7918
|
-
if (this.idMap
|
|
7912
|
+
if (this.idMap.get(task.id) === task)
|
|
7919
7913
|
return;
|
|
7920
|
-
this.idMap
|
|
7914
|
+
this.idMap.set(task.id, task);
|
|
7921
7915
|
if (task.type === "suite") {
|
|
7922
7916
|
task.tasks.forEach((task2) => {
|
|
7923
7917
|
this.updateId(task2);
|
|
@@ -7926,8 +7920,8 @@ class StateManager {
|
|
|
7926
7920
|
}
|
|
7927
7921
|
updateTasks(packs) {
|
|
7928
7922
|
for (const [id, result] of packs) {
|
|
7929
|
-
if (this.idMap
|
|
7930
|
-
this.idMap
|
|
7923
|
+
if (this.idMap.has(id))
|
|
7924
|
+
this.idMap.get(id).result = result;
|
|
7931
7925
|
}
|
|
7932
7926
|
}
|
|
7933
7927
|
}
|
|
@@ -7972,6 +7966,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
7972
7966
|
resolved.testTimeout = resolved.testTimeout ?? 5e3;
|
|
7973
7967
|
resolved.hookTimeout = resolved.hookTimeout ?? 1e4;
|
|
7974
7968
|
resolved.isolate = resolved.isolate ?? true;
|
|
7969
|
+
resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
|
|
7975
7970
|
resolved.watchIgnore = resolved.watchIgnore ?? [/\/node_modules\//, /\/dist\//];
|
|
7976
7971
|
const CI = !!process.env.CI;
|
|
7977
7972
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
@@ -8007,11 +8002,10 @@ async function _transformRequest(ctx, id) {
|
|
|
8007
8002
|
if (result)
|
|
8008
8003
|
result = await ctx.server.ssrTransform(result.code, result.map, id);
|
|
8009
8004
|
}
|
|
8010
|
-
if (result
|
|
8005
|
+
if (result)
|
|
8011
8006
|
withInlineSourcemap(result);
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
}
|
|
8007
|
+
if ((result == null ? void 0 : result.map) && process.env.NODE_V8_COVERAGE)
|
|
8008
|
+
ctx.visitedFilesMap.set(toFilePath(id, ctx.config.root), result.map);
|
|
8015
8009
|
return result;
|
|
8016
8010
|
}
|
|
8017
8011
|
let SOURCEMAPPING_URL = "sourceMa";
|
|
@@ -8090,7 +8084,8 @@ function createWorkerPool(ctx) {
|
|
|
8090
8084
|
return {
|
|
8091
8085
|
runTests: runWithFiles("run"),
|
|
8092
8086
|
collectTests: runWithFiles("collect"),
|
|
8093
|
-
close: () =>
|
|
8087
|
+
close: async () => {
|
|
8088
|
+
}
|
|
8094
8089
|
};
|
|
8095
8090
|
}
|
|
8096
8091
|
function createChannel(ctx) {
|
|
@@ -8120,11 +8115,11 @@ function createChannel(ctx) {
|
|
|
8120
8115
|
},
|
|
8121
8116
|
onCollected(files) {
|
|
8122
8117
|
ctx.state.collectFiles(files);
|
|
8123
|
-
ctx.report("
|
|
8118
|
+
ctx.report("onCollected", files);
|
|
8124
8119
|
},
|
|
8125
|
-
onTaskUpdate(
|
|
8126
|
-
ctx.state.updateTasks(
|
|
8127
|
-
ctx.report("onTaskUpdate",
|
|
8120
|
+
onTaskUpdate(packs) {
|
|
8121
|
+
ctx.state.updateTasks(packs);
|
|
8122
|
+
ctx.report("onTaskUpdate", packs);
|
|
8128
8123
|
},
|
|
8129
8124
|
onUserLog(msg) {
|
|
8130
8125
|
ctx.report("onUserConsoleLog", msg);
|
|
@@ -8187,7 +8182,7 @@ class Vitest {
|
|
|
8187
8182
|
this.runningPromise = void 0;
|
|
8188
8183
|
this._onRestartListeners.forEach((fn) => fn());
|
|
8189
8184
|
if (resolved.coverage.enabled)
|
|
8190
|
-
await
|
|
8185
|
+
await cleanCoverage(resolved.coverage, resolved.coverage.clean);
|
|
8191
8186
|
}
|
|
8192
8187
|
async start(filters) {
|
|
8193
8188
|
this.report("onInit", this);
|
|
@@ -8245,7 +8240,7 @@ class Vitest {
|
|
|
8245
8240
|
this.snapshot.clear();
|
|
8246
8241
|
const files = Array.from(this.changedTests);
|
|
8247
8242
|
this.changedTests.clear();
|
|
8248
|
-
this.
|
|
8243
|
+
this.log("return");
|
|
8249
8244
|
if (this.config.coverage.enabled && this.config.coverage.cleanOnRerun)
|
|
8250
8245
|
await cleanCoverage(this.config.coverage);
|
|
8251
8246
|
await this.report("onWatcherRerun", files, triggerId);
|
|
@@ -8265,8 +8260,8 @@ class Vitest {
|
|
|
8265
8260
|
const onUnlink = (id) => {
|
|
8266
8261
|
id = slash$1(id);
|
|
8267
8262
|
this.invalidates.add(id);
|
|
8268
|
-
if (
|
|
8269
|
-
|
|
8263
|
+
if (this.state.filesMap.has(id)) {
|
|
8264
|
+
this.state.filesMap.delete(id);
|
|
8270
8265
|
this.changedTests.delete(id);
|
|
8271
8266
|
}
|
|
8272
8267
|
};
|
|
@@ -8295,7 +8290,7 @@ class Vitest {
|
|
|
8295
8290
|
if (!mod)
|
|
8296
8291
|
return;
|
|
8297
8292
|
this.invalidates.add(id);
|
|
8298
|
-
if (
|
|
8293
|
+
if (this.state.filesMap.has(id)) {
|
|
8299
8294
|
this.changedTests.add(id);
|
|
8300
8295
|
return;
|
|
8301
8296
|
}
|
|
@@ -8306,8 +8301,17 @@ class Vitest {
|
|
|
8306
8301
|
}
|
|
8307
8302
|
async close() {
|
|
8308
8303
|
var _a;
|
|
8309
|
-
|
|
8310
|
-
|
|
8304
|
+
if (!this.closingPromise) {
|
|
8305
|
+
this.closingPromise = Promise.allSettled([
|
|
8306
|
+
(_a = this.pool) == null ? void 0 : _a.close(),
|
|
8307
|
+
this.server.close()
|
|
8308
|
+
].filter(Boolean)).then((results) => {
|
|
8309
|
+
results.filter((r) => r.status === "rejected").forEach((err) => {
|
|
8310
|
+
this.error("error during close", err.reason);
|
|
8311
|
+
});
|
|
8312
|
+
});
|
|
8313
|
+
}
|
|
8314
|
+
return this.closingPromise;
|
|
8311
8315
|
}
|
|
8312
8316
|
async report(name, ...args) {
|
|
8313
8317
|
await Promise.all(this.reporters.map((r) => {
|
|
@@ -8353,7 +8357,7 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8353
8357
|
await ctx.setServer(options, server2);
|
|
8354
8358
|
haveStarted = true;
|
|
8355
8359
|
if (options.api)
|
|
8356
|
-
|
|
8360
|
+
(await import('./setup-638014f2.js')).setup(ctx);
|
|
8357
8361
|
}
|
|
8358
8362
|
},
|
|
8359
8363
|
MocksPlugin()
|
|
@@ -8362,6 +8366,9 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8362
8366
|
open: options.open,
|
|
8363
8367
|
strictPort: true
|
|
8364
8368
|
},
|
|
8369
|
+
build: {
|
|
8370
|
+
sourcemap: true
|
|
8371
|
+
},
|
|
8365
8372
|
optimizeDeps: {
|
|
8366
8373
|
exclude: [
|
|
8367
8374
|
"vitest"
|
|
@@ -8372,6 +8379,8 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8372
8379
|
await server.pluginContainer.buildStart({});
|
|
8373
8380
|
if (options.api === true)
|
|
8374
8381
|
options.api = defaultPort;
|
|
8382
|
+
if (options.open && !options.api)
|
|
8383
|
+
options.api = defaultPort;
|
|
8375
8384
|
if (typeof options.api === "number")
|
|
8376
8385
|
await server.listen(options.api);
|
|
8377
8386
|
return ctx;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Formatter } from 'picocolors/types';
|
|
|
2
2
|
import { ViteDevServer } from 'vite';
|
|
3
3
|
import { RawSourceMap } from 'source-map-js';
|
|
4
4
|
import { OptionsReceived } from 'pretty-format';
|
|
5
|
-
import { Arrayable as Arrayable$1 } from 'vitest';
|
|
6
5
|
import { MessagePort } from 'worker_threads';
|
|
7
6
|
export { Spy, SpyFn } from 'tinyspy';
|
|
8
7
|
export { assert, default as chai, should } from 'chai';
|
|
@@ -178,11 +177,11 @@ interface WorkerPool {
|
|
|
178
177
|
}
|
|
179
178
|
|
|
180
179
|
declare class StateManager {
|
|
181
|
-
filesMap:
|
|
182
|
-
idMap:
|
|
180
|
+
filesMap: Map<string, File>;
|
|
181
|
+
idMap: Map<string, Task>;
|
|
183
182
|
taskFileMap: WeakMap<Task, File>;
|
|
184
183
|
getFiles(keys?: string[]): File[];
|
|
185
|
-
collectFiles(files
|
|
184
|
+
collectFiles(files?: File[]): void;
|
|
186
185
|
updateId(task: Task): void;
|
|
187
186
|
updateTasks(packs: TaskResultPack[]): void;
|
|
188
187
|
}
|
|
@@ -205,6 +204,7 @@ declare class Vitest {
|
|
|
205
204
|
changedTests: Set<string>;
|
|
206
205
|
visitedFilesMap: Map<string, RawSourceMap>;
|
|
207
206
|
runningPromise?: Promise<void>;
|
|
207
|
+
closingPromise?: Promise<void>;
|
|
208
208
|
isFirstRun: boolean;
|
|
209
209
|
restartsCount: number;
|
|
210
210
|
private _onRestartListeners;
|
|
@@ -235,10 +235,10 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
235
235
|
onInit(ctx: Vitest): void;
|
|
236
236
|
relative(path: string): string;
|
|
237
237
|
onFinished(files?: File[]): Promise<void>;
|
|
238
|
-
onTaskUpdate(
|
|
238
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
239
239
|
isFirstWatchRun: boolean;
|
|
240
240
|
onWatcherStart(): Promise<void>;
|
|
241
|
-
onWatcherRerun(files: string[], trigger
|
|
241
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
242
242
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
243
243
|
onServerRestart(): void;
|
|
244
244
|
reportSummary(files: File[]): Promise<void>;
|
|
@@ -259,21 +259,21 @@ declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions)
|
|
|
259
259
|
declare class DefaultReporter extends BaseReporter {
|
|
260
260
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
261
261
|
rendererOptions: ListRendererOptions;
|
|
262
|
-
|
|
262
|
+
onCollected(): void;
|
|
263
263
|
onFinished(files?: File[]): Promise<void>;
|
|
264
264
|
onWatcherStart(): Promise<void>;
|
|
265
265
|
stopListRender(): Promise<void>;
|
|
266
|
-
onWatcherRerun(files: string[], trigger
|
|
266
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
267
267
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
declare class DotReporter extends BaseReporter {
|
|
271
271
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
272
|
-
|
|
272
|
+
onCollected(): void;
|
|
273
273
|
onFinished(files?: File[]): Promise<void>;
|
|
274
274
|
onWatcherStart(): Promise<void>;
|
|
275
275
|
stopListRender(): Promise<void>;
|
|
276
|
-
onWatcherRerun(files: string[], trigger
|
|
276
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
277
277
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
278
278
|
}
|
|
279
279
|
|
|
@@ -288,7 +288,7 @@ declare const ReportersMap: {
|
|
|
288
288
|
};
|
|
289
289
|
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
290
290
|
|
|
291
|
-
declare type
|
|
291
|
+
declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
292
292
|
interface C8Options {
|
|
293
293
|
/**
|
|
294
294
|
* Enable coverage, pass `--coverage` to enable
|
|
@@ -323,7 +323,7 @@ interface C8Options {
|
|
|
323
323
|
*
|
|
324
324
|
* @default 'text'
|
|
325
325
|
*/
|
|
326
|
-
reporter?: Arrayable
|
|
326
|
+
reporter?: Arrayable<CoverageReporter>;
|
|
327
327
|
/**
|
|
328
328
|
* Exclude coverage under /node_modules/
|
|
329
329
|
*
|
|
@@ -440,12 +440,12 @@ interface RuntimeContext {
|
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
interface Reporter {
|
|
443
|
-
onInit(ctx: Vitest): void;
|
|
444
|
-
|
|
443
|
+
onInit?(ctx: Vitest): void;
|
|
444
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
445
445
|
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
446
|
-
onTaskUpdate?: (
|
|
446
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
447
447
|
onWatcherStart?: () => Awaitable<void>;
|
|
448
|
-
onWatcherRerun?: (files: string[], trigger
|
|
448
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
449
449
|
onServerRestart?: () => Awaitable<void>;
|
|
450
450
|
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
451
451
|
}
|
|
@@ -625,6 +625,10 @@ interface InlineConfig {
|
|
|
625
625
|
* @internal WIP
|
|
626
626
|
*/
|
|
627
627
|
open?: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* run test names with the specified pattern
|
|
630
|
+
*/
|
|
631
|
+
testNamePattern?: string | RegExp;
|
|
628
632
|
/**
|
|
629
633
|
* Listen to port and serve API
|
|
630
634
|
*
|
|
@@ -674,9 +678,10 @@ interface UserConfig extends InlineConfig {
|
|
|
674
678
|
*/
|
|
675
679
|
passWithNoTests?: boolean;
|
|
676
680
|
}
|
|
677
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage'> {
|
|
681
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern'> {
|
|
678
682
|
config?: string;
|
|
679
683
|
filters?: string[];
|
|
684
|
+
testNamePattern?: RegExp;
|
|
680
685
|
depsInline: (string | RegExp)[];
|
|
681
686
|
depsExternal: (string | RegExp)[];
|
|
682
687
|
coverage: ResolvedC8Options;
|
|
@@ -695,7 +700,7 @@ interface WorkerRPC {
|
|
|
695
700
|
onWorkerExit: (code?: number) => void;
|
|
696
701
|
onUserLog: (log: UserConsoleLog) => void;
|
|
697
702
|
onCollected: (files: File[]) => void;
|
|
698
|
-
onTaskUpdate: (pack: TaskResultPack) => void;
|
|
703
|
+
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
699
704
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
700
705
|
}
|
|
701
706
|
|
|
@@ -867,6 +872,15 @@ declare class VitestUtils {
|
|
|
867
872
|
declare const vitest: VitestUtils;
|
|
868
873
|
declare const vi: VitestUtils;
|
|
869
874
|
|
|
875
|
+
interface WebSocketHandlers {
|
|
876
|
+
getFiles(): File[];
|
|
877
|
+
getConfig(): ResolvedConfig;
|
|
878
|
+
getSourceCode(id: string): Promise<string>;
|
|
879
|
+
rerun(files: string[]): Promise<void>;
|
|
880
|
+
}
|
|
881
|
+
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onTaskUpdate'> {
|
|
882
|
+
}
|
|
883
|
+
|
|
870
884
|
declare type VitestInlineConfig = InlineConfig;
|
|
871
885
|
|
|
872
886
|
declare module 'vite' {
|
|
@@ -942,4 +956,4 @@ declare global {
|
|
|
942
956
|
}
|
|
943
957
|
}
|
|
944
958
|
|
|
945
|
-
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, ConstructorArgumentsOf, DoneCallback, Environment, EnvironmentReturn, 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, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, it, spies, spyOn, suite, test, vi, vitest };
|
|
959
|
+
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, ConstructorArgumentsOf, DoneCallback, Environment, EnvironmentReturn, 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, it, spies, spyOn, suite, test, vi, vitest };
|
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-
|
|
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-092f86e3.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-31a38185.js';
|
|
3
3
|
export { f as fn, s as spies, a as spyOn } from './jest-mock-4a754991.js';
|
|
4
4
|
export { assert, default as chai, should } from 'chai';
|
|
5
|
-
import './index-
|
|
5
|
+
import './index-090545ef.js';
|
|
6
6
|
import 'url';
|
|
7
7
|
import 'tty';
|
|
8
8
|
import 'local-pkg';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
|
|
2
2
|
import { RawSourceMap } from 'source-map-js';
|
|
3
|
-
import { Arrayable as Arrayable$1 } from 'vitest';
|
|
4
3
|
import { OptionsReceived } from 'pretty-format';
|
|
5
4
|
|
|
6
5
|
declare abstract class BaseReporter implements Reporter {
|
|
@@ -12,10 +11,10 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
12
11
|
onInit(ctx: Vitest): void;
|
|
13
12
|
relative(path: string): string;
|
|
14
13
|
onFinished(files?: File[]): Promise<void>;
|
|
15
|
-
onTaskUpdate(
|
|
14
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
16
15
|
isFirstWatchRun: boolean;
|
|
17
16
|
onWatcherStart(): Promise<void>;
|
|
18
|
-
onWatcherRerun(files: string[], trigger
|
|
17
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
19
18
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
20
19
|
onServerRestart(): void;
|
|
21
20
|
reportSummary(files: File[]): Promise<void>;
|
|
@@ -36,21 +35,21 @@ declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions)
|
|
|
36
35
|
declare class DefaultReporter extends BaseReporter {
|
|
37
36
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
38
37
|
rendererOptions: ListRendererOptions;
|
|
39
|
-
|
|
38
|
+
onCollected(): void;
|
|
40
39
|
onFinished(files?: File[]): Promise<void>;
|
|
41
40
|
onWatcherStart(): Promise<void>;
|
|
42
41
|
stopListRender(): Promise<void>;
|
|
43
|
-
onWatcherRerun(files: string[], trigger
|
|
42
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
44
43
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
declare class DotReporter extends BaseReporter {
|
|
48
47
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
49
|
-
|
|
48
|
+
onCollected(): void;
|
|
50
49
|
onFinished(files?: File[]): Promise<void>;
|
|
51
50
|
onWatcherStart(): Promise<void>;
|
|
52
51
|
stopListRender(): Promise<void>;
|
|
53
|
-
onWatcherRerun(files: string[], trigger
|
|
52
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
54
53
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -65,7 +64,7 @@ declare const ReportersMap: {
|
|
|
65
64
|
};
|
|
66
65
|
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
67
66
|
|
|
68
|
-
declare type
|
|
67
|
+
declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
69
68
|
interface C8Options {
|
|
70
69
|
/**
|
|
71
70
|
* Enable coverage, pass `--coverage` to enable
|
|
@@ -100,7 +99,7 @@ interface C8Options {
|
|
|
100
99
|
*
|
|
101
100
|
* @default 'text'
|
|
102
101
|
*/
|
|
103
|
-
reporter?: Arrayable
|
|
102
|
+
reporter?: Arrayable<CoverageReporter>;
|
|
104
103
|
/**
|
|
105
104
|
* Exclude coverage under /node_modules/
|
|
106
105
|
*
|
|
@@ -159,12 +158,12 @@ interface Test extends TaskBase {
|
|
|
159
158
|
declare type Task = Test | Suite | File;
|
|
160
159
|
|
|
161
160
|
interface Reporter {
|
|
162
|
-
onInit(ctx: Vitest): void;
|
|
163
|
-
|
|
161
|
+
onInit?(ctx: Vitest): void;
|
|
162
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
164
163
|
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
165
|
-
onTaskUpdate?: (
|
|
164
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
166
165
|
onWatcherStart?: () => Awaitable<void>;
|
|
167
|
-
onWatcherRerun?: (files: string[], trigger
|
|
166
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
168
167
|
onServerRestart?: () => Awaitable<void>;
|
|
169
168
|
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
170
169
|
}
|
|
@@ -335,6 +334,10 @@ interface InlineConfig {
|
|
|
335
334
|
* @internal WIP
|
|
336
335
|
*/
|
|
337
336
|
open?: boolean;
|
|
337
|
+
/**
|
|
338
|
+
* run test names with the specified pattern
|
|
339
|
+
*/
|
|
340
|
+
testNamePattern?: string | RegExp;
|
|
338
341
|
/**
|
|
339
342
|
* Listen to port and serve API
|
|
340
343
|
*
|
|
@@ -384,9 +387,10 @@ interface UserConfig extends InlineConfig {
|
|
|
384
387
|
*/
|
|
385
388
|
passWithNoTests?: boolean;
|
|
386
389
|
}
|
|
387
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage'> {
|
|
390
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern'> {
|
|
388
391
|
config?: string;
|
|
389
392
|
filters?: string[];
|
|
393
|
+
testNamePattern?: RegExp;
|
|
390
394
|
depsInline: (string | RegExp)[];
|
|
391
395
|
depsExternal: (string | RegExp)[];
|
|
392
396
|
coverage: ResolvedC8Options;
|
|
@@ -409,11 +413,11 @@ interface WorkerPool {
|
|
|
409
413
|
}
|
|
410
414
|
|
|
411
415
|
declare class StateManager {
|
|
412
|
-
filesMap:
|
|
413
|
-
idMap:
|
|
416
|
+
filesMap: Map<string, File>;
|
|
417
|
+
idMap: Map<string, Task>;
|
|
414
418
|
taskFileMap: WeakMap<Task, File>;
|
|
415
419
|
getFiles(keys?: string[]): File[];
|
|
416
|
-
collectFiles(files
|
|
420
|
+
collectFiles(files?: File[]): void;
|
|
417
421
|
updateId(task: Task): void;
|
|
418
422
|
updateTasks(packs: TaskResultPack[]): void;
|
|
419
423
|
}
|
|
@@ -436,6 +440,7 @@ declare class Vitest {
|
|
|
436
440
|
changedTests: Set<string>;
|
|
437
441
|
visitedFilesMap: Map<string, RawSourceMap>;
|
|
438
442
|
runningPromise?: Promise<void>;
|
|
443
|
+
closingPromise?: Promise<void>;
|
|
439
444
|
isFirstRun: boolean;
|
|
440
445
|
restartsCount: number;
|
|
441
446
|
private _onRestartListeners;
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
2
|
-
import './index-
|
|
1
|
+
export { c as createVitest } from './index-478354a1.js';
|
|
2
|
+
import './index-090545ef.js';
|
|
3
3
|
import 'url';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
@@ -11,10 +11,10 @@ import 'os';
|
|
|
11
11
|
import 'util';
|
|
12
12
|
import 'stream';
|
|
13
13
|
import 'events';
|
|
14
|
-
import './constants-
|
|
14
|
+
import './constants-22bbd600.js';
|
|
15
15
|
import './magic-string.es-94000aea.js';
|
|
16
16
|
import 'perf_hooks';
|
|
17
|
-
import './diff-
|
|
17
|
+
import './diff-a295cb37.js';
|
|
18
18
|
import './index-648e7ab2.js';
|
|
19
19
|
import './_commonjsHelpers-c9e3b764.js';
|
|
20
20
|
import 'assert';
|