vitest 0.20.0 → 0.20.3
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/browser.d.ts +27 -7
- package/dist/browser.mjs +3 -3
- package/dist/{chunk-api-setup.7c4c8879.mjs → chunk-api-setup.9bff74bb.mjs} +2 -2
- package/dist/{chunk-defaults.1c51d585.mjs → chunk-defaults.6698a2d3.mjs} +1 -1
- package/dist/{chunk-integrations-globals.56a11010.mjs → chunk-integrations-globals.c5b78414.mjs} +1 -1
- package/dist/{chunk-runtime-error.0aa0dc06.mjs → chunk-runtime-error.034e03ba.mjs} +3 -3
- package/dist/{chunk-runtime-hooks.3ee34848.mjs → chunk-runtime-hooks.a8401528.mjs} +1 -1
- package/dist/{chunk-runtime-mocker.0a8f7c5e.mjs → chunk-runtime-mocker.653847b2.mjs} +2 -2
- package/dist/{chunk-vite-node-client.a247c2c2.mjs → chunk-vite-node-client.115caed2.mjs} +1 -1
- package/dist/{chunk-vite-node-externalize.2e90dadf.mjs → chunk-vite-node-externalize.91ae6e85.mjs} +20 -13
- package/dist/{chunk-vite-node-utils.9dfd1e3f.mjs → chunk-vite-node-utils.7e46948f.mjs} +0 -0
- package/dist/cli.mjs +4 -4
- package/dist/entry.mjs +3 -3
- package/dist/index.d.ts +56 -7
- package/dist/index.mjs +1 -1
- package/dist/loader.mjs +3 -2
- package/dist/node.d.ts +27 -7
- package/dist/node.mjs +5 -5
- package/dist/worker.mjs +3 -3
- package/package.json +12 -11
- package/suppress-warnings.cjs +20 -0
package/dist/browser.d.ts
CHANGED
|
@@ -209,18 +209,26 @@ interface CustomEventMap {
|
|
|
209
209
|
type InferCustomEventPayload<T extends string> =
|
|
210
210
|
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
211
211
|
|
|
212
|
+
type ModuleNamespace = Record<string, any> & {
|
|
213
|
+
[Symbol.toStringTag]: 'Module'
|
|
214
|
+
}
|
|
215
|
+
|
|
212
216
|
interface ViteHotContext {
|
|
213
217
|
readonly data: any
|
|
214
218
|
|
|
215
219
|
accept(): void
|
|
216
|
-
accept(cb: (mod:
|
|
217
|
-
accept(dep: string, cb: (mod:
|
|
218
|
-
accept(
|
|
220
|
+
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
|
221
|
+
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
|
222
|
+
accept(
|
|
223
|
+
deps: readonly string[],
|
|
224
|
+
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
225
|
+
): void
|
|
219
226
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
acceptExports(exportNames: string | readonly string[]): void
|
|
228
|
+
acceptExports(
|
|
229
|
+
exportNames: string | readonly string[],
|
|
230
|
+
cb: (mod: ModuleNamespace | undefined) => void
|
|
231
|
+
): void
|
|
224
232
|
|
|
225
233
|
dispose(cb: (data: any) => void): void
|
|
226
234
|
decline(): void
|
|
@@ -574,6 +582,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
574
582
|
private _lastRunTimeout;
|
|
575
583
|
private _lastRunTimer;
|
|
576
584
|
private _lastRunCount;
|
|
585
|
+
private _timeStart;
|
|
577
586
|
constructor();
|
|
578
587
|
onInit(ctx: Vitest): void;
|
|
579
588
|
relative(path: string): string;
|
|
@@ -776,6 +785,12 @@ interface C8Options {
|
|
|
776
785
|
* @default false
|
|
777
786
|
*/
|
|
778
787
|
cleanOnRerun?: boolean;
|
|
788
|
+
/**
|
|
789
|
+
* Check thresholds per file
|
|
790
|
+
*
|
|
791
|
+
* @default false
|
|
792
|
+
*/
|
|
793
|
+
perFile?: boolean;
|
|
779
794
|
/**
|
|
780
795
|
* Allow files from outside of your cwd.
|
|
781
796
|
*
|
|
@@ -1136,6 +1151,11 @@ interface InlineConfig {
|
|
|
1136
1151
|
* @default false
|
|
1137
1152
|
*/
|
|
1138
1153
|
fallbackCJS?: boolean;
|
|
1154
|
+
/**
|
|
1155
|
+
* Use experimental Node loader to resolve imports inside node_modules using Vite resolve algorithm.
|
|
1156
|
+
* @default true
|
|
1157
|
+
*/
|
|
1158
|
+
registerNodeLoader?: boolean;
|
|
1139
1159
|
};
|
|
1140
1160
|
/**
|
|
1141
1161
|
* Base directory to scan for the test files
|
package/dist/browser.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.
|
|
3
|
-
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.a8401528.mjs';
|
|
3
|
+
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.034e03ba.mjs';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
export { chai };
|
|
6
6
|
export { assert, should } from 'chai';
|
|
@@ -17,6 +17,6 @@ import 'fs';
|
|
|
17
17
|
import './chunk-utils-source-map.8198ebd9.mjs';
|
|
18
18
|
import './spy.mjs';
|
|
19
19
|
import 'tinyspy';
|
|
20
|
-
import './chunk-defaults.
|
|
20
|
+
import './chunk-defaults.6698a2d3.mjs';
|
|
21
21
|
import 'module';
|
|
22
22
|
import 'url';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-client.
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-client.115caed2.mjs';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -17,7 +17,7 @@ import './chunk-mock-date.9160e13b.mjs';
|
|
|
17
17
|
import 'path';
|
|
18
18
|
import 'tty';
|
|
19
19
|
import 'local-pkg';
|
|
20
|
-
import './chunk-vite-node-utils.
|
|
20
|
+
import './chunk-vite-node-utils.7e46948f.mjs';
|
|
21
21
|
import 'assert';
|
|
22
22
|
import 'util';
|
|
23
23
|
import 'debug';
|
|
@@ -551,7 +551,7 @@ function isClassLikeName(name) {
|
|
|
551
551
|
function populateGlobal(global, win, options = {}) {
|
|
552
552
|
const { bindFunctions = false } = options;
|
|
553
553
|
const keys = getWindowKeys(global, win);
|
|
554
|
-
const originals = new Map(allowRewrite.map((
|
|
554
|
+
const originals = new Map(allowRewrite.filter((key) => key in global).map((key) => [key, global[key]]));
|
|
555
555
|
const overrideObject = /* @__PURE__ */ new Map();
|
|
556
556
|
for (const key of keys) {
|
|
557
557
|
const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
|
package/dist/{chunk-integrations-globals.56a11010.mjs → chunk-integrations-globals.c5b78414.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as globalApis } from './chunk-constants.16825f0c.mjs';
|
|
2
|
-
import { i as index } from './chunk-runtime-hooks.
|
|
2
|
+
import { i as index } from './chunk-runtime-hooks.a8401528.mjs';
|
|
3
3
|
import 'url';
|
|
4
4
|
import './chunk-mock-date.9160e13b.mjs';
|
|
5
5
|
import 'path';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as environments, t as takeCoverage, p as pLimit } from './chunk-defaults.
|
|
2
|
-
import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.
|
|
1
|
+
import { e as environments, t as takeCoverage, p as pLimit } from './chunk-defaults.6698a2d3.mjs';
|
|
2
|
+
import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.a8401528.mjs';
|
|
3
3
|
import { h as deepClone, k as getType, l as isNode, R as RealDate, t as toArray, o as relativePath, q as isBrowser, u as partitionSuiteChildren, v as shuffle, w as hasTests, x as hasFailed, e as getFullName } from './chunk-mock-date.9160e13b.mjs';
|
|
4
4
|
import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
5
5
|
import { r as rpc } from './chunk-runtime-rpc.dbf0b31d.mjs';
|
|
@@ -130,7 +130,7 @@ async function setupGlobalEnv(config) {
|
|
|
130
130
|
if (isNode)
|
|
131
131
|
await setupConsoleLogSpy();
|
|
132
132
|
if (config.globals)
|
|
133
|
-
(await import('./chunk-integrations-globals.
|
|
133
|
+
(await import('./chunk-integrations-globals.c5b78414.mjs')).registerApiGlobally();
|
|
134
134
|
}
|
|
135
135
|
function setupDefines(defines) {
|
|
136
136
|
for (const key in defines)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { V as ViteNodeRunner } from './chunk-vite-node-client.
|
|
1
|
+
import { V as ViteNodeRunner } from './chunk-vite-node-client.115caed2.mjs';
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
3
|
import { M as isWindows, N as mergeSlashes, d as dirname, j as join, z as basename, y as resolve, s as slash, k as getType, O as getAllProperties } from './chunk-mock-date.9160e13b.mjs';
|
|
4
4
|
import { existsSync, readdirSync } from 'fs';
|
|
5
|
-
import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.
|
|
5
|
+
import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.7e46948f.mjs';
|
|
6
6
|
import { d as distDir } from './chunk-constants.16825f0c.mjs';
|
|
7
7
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import { createRequire } from 'module';
|
|
|
2
2
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
3
3
|
import vm from 'vm';
|
|
4
4
|
import { y as resolve, d as dirname, B as isAbsolute, L as extname } from './chunk-mock-date.9160e13b.mjs';
|
|
5
|
-
import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.
|
|
5
|
+
import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.7e46948f.mjs';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
7
|
|
|
8
8
|
const debugExecute = createDebug("vite-node:client:execute");
|
package/dist/{chunk-vite-node-externalize.2e90dadf.mjs → chunk-vite-node-externalize.91ae6e85.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { j as join, z as basename, d as dirname, y as resolve, A as AggregateErrorPonyfill, p as picocolors, B as isAbsolute, C as relative, s as slash$2, l as isNode, o as relativePath, D as getTests, e as getFullName, x as hasFailed, E as hasFailedSnapshot, F as getSuites, v as shuffle, t as toArray$1, G as normalize, n as noop$1, H as deepMerge, I as toNamespacedPath, g as getCallLastIndex, f as notNullish, J as ensurePackageInstalled, K as stdout } from './chunk-mock-date.9160e13b.mjs';
|
|
2
|
-
import { p as pLimit, c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage, d as envPackageNames } from './chunk-defaults.
|
|
2
|
+
import { p as pLimit, c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage, d as envPackageNames } from './chunk-defaults.6698a2d3.mjs';
|
|
3
3
|
import { loadConfigFromFile, createServer, mergeConfig } from 'vite';
|
|
4
4
|
import path$a from 'path';
|
|
5
5
|
import _url, { fileURLToPath } from 'url';
|
|
@@ -11,9 +11,9 @@ import util$2 from 'util';
|
|
|
11
11
|
import require$$0$1 from 'stream';
|
|
12
12
|
import require$$2 from 'events';
|
|
13
13
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
14
|
-
import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.
|
|
14
|
+
import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.115caed2.mjs';
|
|
15
15
|
import createDebug from 'debug';
|
|
16
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.
|
|
16
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.7e46948f.mjs';
|
|
17
17
|
import { MessageChannel } from 'worker_threads';
|
|
18
18
|
import { Tinypool } from 'tinypool';
|
|
19
19
|
import { performance } from 'perf_hooks';
|
|
@@ -26,7 +26,7 @@ import MagicString from './chunk-magic-string.efe26975.mjs';
|
|
|
26
26
|
import require$$0$2 from 'readline';
|
|
27
27
|
import { p as prompts } from './vendor-index.de788b6a.mjs';
|
|
28
28
|
|
|
29
|
-
var version$1 = "0.20.
|
|
29
|
+
var version$1 = "0.20.3";
|
|
30
30
|
|
|
31
31
|
class EndError extends Error {
|
|
32
32
|
constructor(value) {
|
|
@@ -7014,13 +7014,13 @@ function createPool(ctx) {
|
|
|
7014
7014
|
useAtomics: false,
|
|
7015
7015
|
maxThreads,
|
|
7016
7016
|
minThreads,
|
|
7017
|
-
execArgv: [
|
|
7017
|
+
execArgv: ctx.config.deps.registerNodeLoader ? [
|
|
7018
7018
|
"--require",
|
|
7019
7019
|
suppressLoaderWarningsPath,
|
|
7020
7020
|
"--experimental-loader",
|
|
7021
7021
|
loaderPath,
|
|
7022
7022
|
...conditions || []
|
|
7023
|
-
]
|
|
7023
|
+
] : []
|
|
7024
7024
|
};
|
|
7025
7025
|
if (ctx.config.isolate) {
|
|
7026
7026
|
options.isolateWorkers = true;
|
|
@@ -7292,6 +7292,9 @@ function elegantSpinner() {
|
|
|
7292
7292
|
return spinnerFrames[index];
|
|
7293
7293
|
};
|
|
7294
7294
|
}
|
|
7295
|
+
function formatTimeString(date) {
|
|
7296
|
+
return date.toTimeString().split(" ")[0];
|
|
7297
|
+
}
|
|
7295
7298
|
|
|
7296
7299
|
var _a;
|
|
7297
7300
|
const BADGE_PADDING = " ";
|
|
@@ -7313,6 +7316,7 @@ class BaseReporter {
|
|
|
7313
7316
|
this._filesInWatchMode = /* @__PURE__ */ new Map();
|
|
7314
7317
|
this._lastRunTimeout = 0;
|
|
7315
7318
|
this._lastRunCount = 0;
|
|
7319
|
+
this._timeStart = new Date();
|
|
7316
7320
|
this.registerUnhandledRejection();
|
|
7317
7321
|
}
|
|
7318
7322
|
onInit(ctx) {
|
|
@@ -7426,6 +7430,7 @@ ${BADGE}${TRIGGER}
|
|
|
7426
7430
|
${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
7427
7431
|
`);
|
|
7428
7432
|
}
|
|
7433
|
+
this._timeStart = new Date();
|
|
7429
7434
|
this.start = performance.now();
|
|
7430
7435
|
}
|
|
7431
7436
|
onUserConsoleLog(log) {
|
|
@@ -7496,10 +7501,11 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7496
7501
|
}
|
|
7497
7502
|
logger.log(padTitle("Test Files"), getStateString(files));
|
|
7498
7503
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
7504
|
+
logger.log(padTitle("Start at"), formatTimeString(this._timeStart));
|
|
7499
7505
|
if (this.watchFilters)
|
|
7500
|
-
logger.log(padTitle("
|
|
7506
|
+
logger.log(padTitle("Duration"), time(threadTime));
|
|
7501
7507
|
else
|
|
7502
|
-
logger.log(padTitle("
|
|
7508
|
+
logger.log(padTitle("Duration"), time(executionTime) + picocolors.exports.gray(` (setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
|
|
7503
7509
|
logger.log();
|
|
7504
7510
|
}
|
|
7505
7511
|
async printTaskErrors(tasks, errorDivider) {
|
|
@@ -8530,7 +8536,7 @@ function resolveApiConfig(options) {
|
|
|
8530
8536
|
return api;
|
|
8531
8537
|
}
|
|
8532
8538
|
function resolveConfig(options, viteConfig) {
|
|
8533
|
-
var _a, _b, _c, _d;
|
|
8539
|
+
var _a, _b, _c, _d, _e;
|
|
8534
8540
|
if (options.dom) {
|
|
8535
8541
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
8536
8542
|
console.warn(picocolors.exports.yellow(`${picocolors.exports.inverse(picocolors.exports.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`));
|
|
@@ -8567,6 +8573,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
8567
8573
|
resolved.deps.inline.push(...extraInlineDeps);
|
|
8568
8574
|
}
|
|
8569
8575
|
}
|
|
8576
|
+
(_c = resolved.deps).registerNodeLoader ?? (_c.registerNodeLoader = typeof process.versions.pnp === "undefined");
|
|
8570
8577
|
resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
|
|
8571
8578
|
const CI = !!process.env.CI;
|
|
8572
8579
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
@@ -8595,11 +8602,11 @@ function resolveConfig(options, viteConfig) {
|
|
|
8595
8602
|
resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
|
|
8596
8603
|
resolved.css ?? (resolved.css = {});
|
|
8597
8604
|
if (typeof resolved.css === "object")
|
|
8598
|
-
(
|
|
8605
|
+
(_d = resolved.css).include ?? (_d.include = [/\.module\./]);
|
|
8599
8606
|
resolved.cache ?? (resolved.cache = { dir: "" });
|
|
8600
8607
|
if (resolved.cache)
|
|
8601
8608
|
resolved.cache.dir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir);
|
|
8602
|
-
if (!((
|
|
8609
|
+
if (!((_e = resolved.sequence) == null ? void 0 : _e.sequencer)) {
|
|
8603
8610
|
resolved.sequence ?? (resolved.sequence = {});
|
|
8604
8611
|
resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
|
|
8605
8612
|
}
|
|
@@ -9092,7 +9099,7 @@ createLogUpdate(process$1.stdout);
|
|
|
9092
9099
|
|
|
9093
9100
|
createLogUpdate(process$1.stderr);
|
|
9094
9101
|
|
|
9095
|
-
var version = "0.20.
|
|
9102
|
+
var version = "0.20.3";
|
|
9096
9103
|
|
|
9097
9104
|
function fileFromParsedStack(stack) {
|
|
9098
9105
|
var _a, _b;
|
|
@@ -10045,7 +10052,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10045
10052
|
await ctx.setServer(options, server);
|
|
10046
10053
|
haveStarted = true;
|
|
10047
10054
|
if (options.api && options.watch)
|
|
10048
|
-
(await import('./chunk-api-setup.
|
|
10055
|
+
(await import('./chunk-api-setup.9bff74bb.mjs')).setup(ctx);
|
|
10049
10056
|
} catch (err) {
|
|
10050
10057
|
ctx.logger.printError(err, true);
|
|
10051
10058
|
process.exit(1);
|
|
File without changes
|
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { p as picocolors } from './chunk-mock-date.9160e13b.mjs';
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.91ae6e85.mjs';
|
|
4
4
|
import 'path';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
|
-
import './chunk-defaults.
|
|
7
|
+
import './chunk-defaults.6698a2d3.mjs';
|
|
8
8
|
import 'fs';
|
|
9
9
|
import 'module';
|
|
10
10
|
import 'url';
|
|
@@ -15,9 +15,9 @@ import 'os';
|
|
|
15
15
|
import 'util';
|
|
16
16
|
import 'stream';
|
|
17
17
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
18
|
-
import './chunk-vite-node-client.
|
|
18
|
+
import './chunk-vite-node-client.115caed2.mjs';
|
|
19
19
|
import 'vm';
|
|
20
|
-
import './chunk-vite-node-utils.
|
|
20
|
+
import './chunk-vite-node-utils.7e46948f.mjs';
|
|
21
21
|
import 'assert';
|
|
22
22
|
import 'debug';
|
|
23
23
|
import 'worker_threads';
|
package/dist/entry.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
2
|
import { a as resetModules } from './chunk-mock-date.9160e13b.mjs';
|
|
3
|
-
import { f as envs } from './chunk-defaults.
|
|
4
|
-
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.
|
|
3
|
+
import { f as envs } from './chunk-defaults.6698a2d3.mjs';
|
|
4
|
+
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.034e03ba.mjs';
|
|
5
5
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
6
6
|
import 'path';
|
|
7
7
|
import 'tty';
|
|
8
8
|
import 'local-pkg';
|
|
9
9
|
import 'module';
|
|
10
10
|
import 'url';
|
|
11
|
-
import './chunk-runtime-hooks.
|
|
11
|
+
import './chunk-runtime-hooks.a8401528.mjs';
|
|
12
12
|
import './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
13
13
|
import 'util';
|
|
14
14
|
import 'chai';
|
package/dist/index.d.ts
CHANGED
|
@@ -209,18 +209,26 @@ interface CustomEventMap {
|
|
|
209
209
|
type InferCustomEventPayload<T extends string> =
|
|
210
210
|
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
211
211
|
|
|
212
|
+
type ModuleNamespace = Record<string, any> & {
|
|
213
|
+
[Symbol.toStringTag]: 'Module'
|
|
214
|
+
}
|
|
215
|
+
|
|
212
216
|
interface ViteHotContext {
|
|
213
217
|
readonly data: any
|
|
214
218
|
|
|
215
219
|
accept(): void
|
|
216
|
-
accept(cb: (mod:
|
|
217
|
-
accept(dep: string, cb: (mod:
|
|
218
|
-
accept(
|
|
220
|
+
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
|
221
|
+
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
|
222
|
+
accept(
|
|
223
|
+
deps: readonly string[],
|
|
224
|
+
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
225
|
+
): void
|
|
219
226
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
acceptExports(exportNames: string | readonly string[]): void
|
|
228
|
+
acceptExports(
|
|
229
|
+
exportNames: string | readonly string[],
|
|
230
|
+
cb: (mod: ModuleNamespace | undefined) => void
|
|
231
|
+
): void
|
|
224
232
|
|
|
225
233
|
dispose(cb: (data: any) => void): void
|
|
226
234
|
decline(): void
|
|
@@ -574,6 +582,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
574
582
|
private _lastRunTimeout;
|
|
575
583
|
private _lastRunTimer;
|
|
576
584
|
private _lastRunCount;
|
|
585
|
+
private _timeStart;
|
|
577
586
|
constructor();
|
|
578
587
|
onInit(ctx: Vitest): void;
|
|
579
588
|
relative(path: string): string;
|
|
@@ -776,6 +785,12 @@ interface C8Options {
|
|
|
776
785
|
* @default false
|
|
777
786
|
*/
|
|
778
787
|
cleanOnRerun?: boolean;
|
|
788
|
+
/**
|
|
789
|
+
* Check thresholds per file
|
|
790
|
+
*
|
|
791
|
+
* @default false
|
|
792
|
+
*/
|
|
793
|
+
perFile?: boolean;
|
|
779
794
|
/**
|
|
780
795
|
* Allow files from outside of your cwd.
|
|
781
796
|
*
|
|
@@ -1136,6 +1151,11 @@ interface InlineConfig {
|
|
|
1136
1151
|
* @default false
|
|
1137
1152
|
*/
|
|
1138
1153
|
fallbackCJS?: boolean;
|
|
1154
|
+
/**
|
|
1155
|
+
* Use experimental Node loader to resolve imports inside node_modules using Vite resolve algorithm.
|
|
1156
|
+
* @default true
|
|
1157
|
+
*/
|
|
1158
|
+
registerNodeLoader?: boolean;
|
|
1139
1159
|
};
|
|
1140
1160
|
/**
|
|
1141
1161
|
* Base directory to scan for the test files
|
|
@@ -1851,11 +1871,19 @@ interface Mock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TA
|
|
|
1851
1871
|
new (...args: TArgs): TReturns;
|
|
1852
1872
|
(...args: TArgs): TReturns;
|
|
1853
1873
|
}
|
|
1874
|
+
interface PartialMock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, Partial<TReturns>> {
|
|
1875
|
+
new (...args: TArgs): TReturns;
|
|
1876
|
+
(...args: TArgs): TReturns;
|
|
1877
|
+
}
|
|
1854
1878
|
declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? Mock<ConstructorParameters<T>, R> : T;
|
|
1855
1879
|
declare type MockedFunction<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & {
|
|
1856
1880
|
[K in keyof T]: T[K];
|
|
1857
1881
|
};
|
|
1882
|
+
declare type PartiallyMockedFunction<T extends Procedure> = PartialMock<Parameters<T>, ReturnType<T>> & {
|
|
1883
|
+
[K in keyof T]: T[K];
|
|
1884
|
+
};
|
|
1858
1885
|
declare type MockedFunctionDeep<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
|
|
1886
|
+
declare type PartiallyMockedFunctionDeep<T extends Procedure> = PartialMock<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
|
|
1859
1887
|
declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
1860
1888
|
[K in Methods<T>]: T[K] extends Procedure ? MockedFunction<T[K]> : T[K];
|
|
1861
1889
|
} & {
|
|
@@ -1867,7 +1895,9 @@ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
|
1867
1895
|
[K in Properties<T>]: MaybeMockedDeep<T[K]>;
|
|
1868
1896
|
};
|
|
1869
1897
|
declare type MaybeMockedDeep<T> = T extends Procedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
1898
|
+
declare type MaybePartiallyMockedDeep<T> = T extends Procedure ? PartiallyMockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
1870
1899
|
declare type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
1900
|
+
declare type MaybePartiallyMocked<T> = T extends Procedure ? PartiallyMockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
1871
1901
|
interface Constructable {
|
|
1872
1902
|
new (...args: any[]): any;
|
|
1873
1903
|
}
|
|
@@ -1985,6 +2015,8 @@ declare class VitestUtils {
|
|
|
1985
2015
|
importMock<T>(path: string): Promise<MaybeMockedDeep<T>>;
|
|
1986
2016
|
/**
|
|
1987
2017
|
* Type helpers for TypeScript. In reality just returns the object that was passed.
|
|
2018
|
+
*
|
|
2019
|
+
* When `partial` is `true` it will expect a `Partial<T>` as a return value.
|
|
1988
2020
|
* @example
|
|
1989
2021
|
* import example from './example'
|
|
1990
2022
|
* vi.mock('./example')
|
|
@@ -1998,9 +2030,26 @@ declare class VitestUtils {
|
|
|
1998
2030
|
* })
|
|
1999
2031
|
* @param item Anything that can be mocked
|
|
2000
2032
|
* @param deep If the object is deeply mocked
|
|
2033
|
+
* @param options If the object is partially or deeply mocked
|
|
2001
2034
|
*/
|
|
2002
2035
|
mocked<T>(item: T, deep?: false): MaybeMocked<T>;
|
|
2003
2036
|
mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
|
2037
|
+
mocked<T>(item: T, options: {
|
|
2038
|
+
partial?: false;
|
|
2039
|
+
deep?: false;
|
|
2040
|
+
}): MaybeMocked<T>;
|
|
2041
|
+
mocked<T>(item: T, options: {
|
|
2042
|
+
partial?: false;
|
|
2043
|
+
deep: true;
|
|
2044
|
+
}): MaybeMockedDeep<T>;
|
|
2045
|
+
mocked<T>(item: T, options: {
|
|
2046
|
+
partial: true;
|
|
2047
|
+
deep?: false;
|
|
2048
|
+
}): MaybePartiallyMocked<T>;
|
|
2049
|
+
mocked<T>(item: T, options: {
|
|
2050
|
+
partial: true;
|
|
2051
|
+
deep: true;
|
|
2052
|
+
}): MaybePartiallyMockedDeep<T>;
|
|
2004
2053
|
isMockFunction(fn: any): fn is EnhancedSpy;
|
|
2005
2054
|
clearAllMocks(): this;
|
|
2006
2055
|
resetAllMocks(): this;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.a8401528.mjs';
|
|
3
3
|
import * as chai from 'chai';
|
|
4
4
|
export { chai };
|
|
5
5
|
export { assert, should } from 'chai';
|
package/dist/loader.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from 'url';
|
|
2
|
-
import { i as isNodeBuiltin, d as normalizeModuleId } from './chunk-vite-node-utils.
|
|
2
|
+
import { i as isNodeBuiltin, d as normalizeModuleId } from './chunk-vite-node-utils.7e46948f.mjs';
|
|
3
3
|
import './chunk-mock-date.9160e13b.mjs';
|
|
4
4
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
5
5
|
import 'module';
|
|
@@ -22,7 +22,8 @@ const resolve = async (url, context, next) => {
|
|
|
22
22
|
const resolved = await resolver(id, importer);
|
|
23
23
|
if (resolved) {
|
|
24
24
|
return {
|
|
25
|
-
url: pathToFileURL(resolved.id).toString()
|
|
25
|
+
url: pathToFileURL(resolved.id).toString(),
|
|
26
|
+
shortCircuit: true
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
}
|
package/dist/node.d.ts
CHANGED
|
@@ -51,18 +51,26 @@ interface CustomEventMap {
|
|
|
51
51
|
type InferCustomEventPayload<T extends string> =
|
|
52
52
|
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
53
53
|
|
|
54
|
+
type ModuleNamespace = Record<string, any> & {
|
|
55
|
+
[Symbol.toStringTag]: 'Module'
|
|
56
|
+
}
|
|
57
|
+
|
|
54
58
|
interface ViteHotContext {
|
|
55
59
|
readonly data: any
|
|
56
60
|
|
|
57
61
|
accept(): void
|
|
58
|
-
accept(cb: (mod:
|
|
59
|
-
accept(dep: string, cb: (mod:
|
|
60
|
-
accept(
|
|
62
|
+
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
|
63
|
+
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
|
64
|
+
accept(
|
|
65
|
+
deps: readonly string[],
|
|
66
|
+
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
67
|
+
): void
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
acceptExports(exportNames: string | readonly string[]): void
|
|
70
|
+
acceptExports(
|
|
71
|
+
exportNames: string | readonly string[],
|
|
72
|
+
cb: (mod: ModuleNamespace | undefined) => void
|
|
73
|
+
): void
|
|
66
74
|
|
|
67
75
|
dispose(cb: (data: any) => void): void
|
|
68
76
|
decline(): void
|
|
@@ -391,6 +399,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
391
399
|
private _lastRunTimeout;
|
|
392
400
|
private _lastRunTimer;
|
|
393
401
|
private _lastRunCount;
|
|
402
|
+
private _timeStart;
|
|
394
403
|
constructor();
|
|
395
404
|
onInit(ctx: Vitest): void;
|
|
396
405
|
relative(path: string): string;
|
|
@@ -604,6 +613,12 @@ interface C8Options {
|
|
|
604
613
|
* @default false
|
|
605
614
|
*/
|
|
606
615
|
cleanOnRerun?: boolean;
|
|
616
|
+
/**
|
|
617
|
+
* Check thresholds per file
|
|
618
|
+
*
|
|
619
|
+
* @default false
|
|
620
|
+
*/
|
|
621
|
+
perFile?: boolean;
|
|
607
622
|
/**
|
|
608
623
|
* Allow files from outside of your cwd.
|
|
609
624
|
*
|
|
@@ -903,6 +918,11 @@ interface InlineConfig {
|
|
|
903
918
|
* @default false
|
|
904
919
|
*/
|
|
905
920
|
fallbackCJS?: boolean;
|
|
921
|
+
/**
|
|
922
|
+
* Use experimental Node loader to resolve imports inside node_modules using Vite resolve algorithm.
|
|
923
|
+
* @default true
|
|
924
|
+
*/
|
|
925
|
+
registerNodeLoader?: boolean;
|
|
906
926
|
};
|
|
907
927
|
/**
|
|
908
928
|
* Base directory to scan for the test files
|
package/dist/node.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
1
|
+
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.91ae6e85.mjs';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.653847b2.mjs';
|
|
3
3
|
import './chunk-mock-date.9160e13b.mjs';
|
|
4
4
|
import 'path';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
|
-
import './chunk-defaults.
|
|
7
|
+
import './chunk-defaults.6698a2d3.mjs';
|
|
8
8
|
import 'fs';
|
|
9
9
|
import 'module';
|
|
10
10
|
import 'url';
|
|
@@ -16,9 +16,9 @@ import 'util';
|
|
|
16
16
|
import 'stream';
|
|
17
17
|
import 'events';
|
|
18
18
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
19
|
-
import './chunk-vite-node-client.
|
|
19
|
+
import './chunk-vite-node-client.115caed2.mjs';
|
|
20
20
|
import 'vm';
|
|
21
|
-
import './chunk-vite-node-utils.
|
|
21
|
+
import './chunk-vite-node-utils.7e46948f.mjs';
|
|
22
22
|
import 'assert';
|
|
23
23
|
import 'debug';
|
|
24
24
|
import 'worker_threads';
|
package/dist/worker.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { y as resolve } from './chunk-mock-date.9160e13b.mjs';
|
|
2
|
-
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.
|
|
2
|
+
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.115caed2.mjs';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
4
|
import { d as distDir } from './chunk-constants.16825f0c.mjs';
|
|
5
|
-
import { e as executeInViteNode } from './chunk-runtime-mocker.
|
|
5
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.653847b2.mjs';
|
|
6
6
|
import { r as rpc } from './chunk-runtime-rpc.dbf0b31d.mjs';
|
|
7
7
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
8
8
|
import 'path';
|
|
@@ -11,7 +11,7 @@ import 'local-pkg';
|
|
|
11
11
|
import 'module';
|
|
12
12
|
import 'url';
|
|
13
13
|
import 'vm';
|
|
14
|
-
import './chunk-vite-node-utils.
|
|
14
|
+
import './chunk-vite-node-utils.7e46948f.mjs';
|
|
15
15
|
import 'fs';
|
|
16
16
|
import 'assert';
|
|
17
17
|
import 'util';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.3",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"dist",
|
|
56
56
|
"bin",
|
|
57
57
|
"*.d.ts",
|
|
58
|
-
"*.mjs"
|
|
58
|
+
"*.mjs",
|
|
59
|
+
"*.cjs"
|
|
59
60
|
],
|
|
60
61
|
"engines": {
|
|
61
62
|
"node": ">=v14.16.0"
|
|
@@ -101,17 +102,17 @@
|
|
|
101
102
|
},
|
|
102
103
|
"devDependencies": {
|
|
103
104
|
"@antfu/install-pkg": "^0.1.0",
|
|
104
|
-
"@edge-runtime/vm": "1.1.0-beta.
|
|
105
|
+
"@edge-runtime/vm": "1.1.0-beta.23",
|
|
105
106
|
"@sinonjs/fake-timers": "^9.1.2",
|
|
106
107
|
"@types/diff": "^5.0.2",
|
|
107
|
-
"@types/jsdom": "^
|
|
108
|
+
"@types/jsdom": "^20.0.0",
|
|
108
109
|
"@types/micromatch": "^4.0.2",
|
|
109
110
|
"@types/natural-compare": "^1.4.1",
|
|
110
111
|
"@types/prompts": "^2.4.0",
|
|
111
112
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
112
|
-
"@vitest/ui": "0.20.
|
|
113
|
+
"@vitest/ui": "0.20.3",
|
|
113
114
|
"birpc": "^0.2.3",
|
|
114
|
-
"c8": "^7.
|
|
115
|
+
"c8": "^7.12.0",
|
|
115
116
|
"cac": "^6.7.12",
|
|
116
117
|
"chai-subset": "^1.6.0",
|
|
117
118
|
"cli-truncate": "^3.1.0",
|
|
@@ -120,12 +121,12 @@
|
|
|
120
121
|
"fast-glob": "^3.2.11",
|
|
121
122
|
"find-up": "^6.3.0",
|
|
122
123
|
"flatted": "^3.2.6",
|
|
123
|
-
"happy-dom": "^6.0.
|
|
124
|
-
"jsdom": "^
|
|
124
|
+
"happy-dom": "^6.0.4",
|
|
125
|
+
"jsdom": "^20.0.0",
|
|
125
126
|
"log-update": "^5.0.1",
|
|
126
127
|
"magic-string": "^0.26.2",
|
|
127
128
|
"micromatch": "^4.0.5",
|
|
128
|
-
"mlly": "^0.5.
|
|
129
|
+
"mlly": "^0.5.5",
|
|
129
130
|
"natural-compare": "^1.4.0",
|
|
130
131
|
"p-limit": "^4.0.0",
|
|
131
132
|
"pathe": "^0.2.0",
|
|
@@ -133,11 +134,11 @@
|
|
|
133
134
|
"pkg-types": "^0.3.3",
|
|
134
135
|
"pretty-format": "^27.5.1",
|
|
135
136
|
"prompts": "^2.4.2",
|
|
136
|
-
"rollup": "^2.77.
|
|
137
|
+
"rollup": "^2.77.2",
|
|
137
138
|
"source-map-js": "^1.0.2",
|
|
138
139
|
"strip-ansi": "^7.0.1",
|
|
139
140
|
"typescript": "^4.7.4",
|
|
140
|
-
"vite-node": "0.20.
|
|
141
|
+
"vite-node": "0.20.3",
|
|
141
142
|
"ws": "^8.8.1"
|
|
142
143
|
},
|
|
143
144
|
"scripts": {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// borrowed from tsx implementation:
|
|
2
|
+
// https://github.com/esbuild-kit/tsx
|
|
3
|
+
|
|
4
|
+
const ignoreWarnings = new Set([
|
|
5
|
+
'--experimental-loader is an experimental feature. This feature could change at any time',
|
|
6
|
+
'Custom ESM Loaders is an experimental feature. This feature could change at any time',
|
|
7
|
+
])
|
|
8
|
+
|
|
9
|
+
const { emit } = process
|
|
10
|
+
|
|
11
|
+
process.emit = function (event, warning) {
|
|
12
|
+
if (
|
|
13
|
+
event === 'warning'
|
|
14
|
+
&& ignoreWarnings.has(warning.message)
|
|
15
|
+
)
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line prefer-rest-params
|
|
19
|
+
return Reflect.apply(emit, this, arguments)
|
|
20
|
+
}
|