vitest 4.0.0-beta.16 → 4.0.0-beta.18
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/browser/context.d.ts +1 -0
- package/dist/browser.d.ts +16 -3
- package/dist/browser.js +1 -1
- package/dist/chunks/{browser.d.CM1rjKAX.d.ts → browser.d.CCG7W26I.d.ts} +1 -1
- package/dist/chunks/{cac.BUHfInSv.js → cac.DYnuYoJK.js} +7 -7
- package/dist/chunks/{cli-api.BB9IOXn3.js → cli-api.xhe4uqTX.js} +15 -7
- package/dist/chunks/{config.d.DGazh2r6.d.ts → config.d.C4PpNy7v.d.ts} +1 -1
- package/dist/chunks/{coverage.3htTSxXZ.js → coverage.Ds84cgzV.js} +85 -43
- package/dist/chunks/{creator.Daoa5_gR.js → creator.DucAaYBz.js} +1 -1
- package/dist/chunks/{global.d.YxmikCHu.d.ts → global.d.RTA0rbJI.d.ts} +2 -1
- package/dist/chunks/{globals.DC4ntO86.js → globals.CwYe1aG7.js} +2 -2
- package/dist/chunks/{index.Dnl38iQ_.js → index.Bcjk8TKX.js} +1 -1
- package/dist/chunks/{index.Bt-upxGS.js → index.CbWINfS7.js} +29 -4
- package/dist/chunks/{index.DehVUBn4.js → index.D2gVI9Ck.js} +1 -1
- package/dist/chunks/{index.01uBqPwR.js → index.eEkl9h8v.js} +1 -1
- package/dist/chunks/{moduleRunner.d.CTZUg34g.d.ts → moduleRunner.d.aXWuQhZN.d.ts} +1 -1
- package/dist/chunks/{plugin.d.DvkMsuLk.d.ts → plugin.d.XtKKWlOO.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DhY37FSs.d.ts → reporters.d.BJ_OuJGZ.d.ts} +48 -17
- package/dist/chunks/{resolveSnapshotEnvironment.BsJpmVZR.js → resolveSnapshotEnvironment.tw2a5ux8.js} +2 -2
- package/dist/chunks/{setup-common.BewgbkTd.js → setup-common.DgXU7Yho.js} +1 -1
- package/dist/chunks/{test.CTuWuHYH.js → test.C3RPt8JR.js} +1 -1
- package/dist/chunks/{vi.B2--mG9U.js → vi.BZvkKVkM.js} +1 -1
- package/dist/chunks/{worker.DVTUM2IW.js → worker.CdzokOSx.js} +1 -1
- package/dist/chunks/{worker.d.B8jq7m7O.d.ts → worker.d.DSgBAZPX.d.ts} +1 -1
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +6 -6
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +1 -1
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +2 -2
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/node.d.ts +8 -8
- package/dist/node.js +7 -7
- package/dist/reporters.d.ts +4 -4
- package/dist/reporters.js +2 -2
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +2 -2
- package/dist/worker-base.js +7 -7
- package/dist/worker-vm.js +2 -2
- package/dist/workers/runVmTests.js +5 -5
- package/package.json +15 -16
package/browser/context.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export * from '@vitest/browser-playwright/context'
|
|
|
4
4
|
export * from '@vitest/browser-webdriverio/context'
|
|
5
5
|
// @ts-ignore -- @vitest/browser-preview might not be installed
|
|
6
6
|
export * from '@vitest/browser-preview/context'
|
|
7
|
+
export { BrowserCommands, FsOptions } from 'vitest/internal/browser'
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.C4PpNy7v.js';
|
|
2
2
|
import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
|
|
3
3
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
4
|
-
import { V as VitestModuleRunner } from './chunks/moduleRunner.d.
|
|
4
|
+
import { V as VitestModuleRunner } from './chunks/moduleRunner.d.aXWuQhZN.js';
|
|
5
5
|
export { collectTests, startTests } from '@vitest/runner';
|
|
6
6
|
import * as _vitest_spy from '@vitest/spy';
|
|
7
7
|
export { _vitest_spy as SpyModule };
|
|
@@ -15,7 +15,7 @@ import '@vitest/pretty-format';
|
|
|
15
15
|
import '@vitest/snapshot';
|
|
16
16
|
import 'node:vm';
|
|
17
17
|
import 'vite/module-runner';
|
|
18
|
-
import './chunks/worker.d.
|
|
18
|
+
import './chunks/worker.d.DSgBAZPX.js';
|
|
19
19
|
import './chunks/environment.d.CrsxCzP1.js';
|
|
20
20
|
import '@vitest/mocker';
|
|
21
21
|
import './chunks/mocker.d.BE_2ls6u.js';
|
|
@@ -32,4 +32,17 @@ declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
|
|
|
32
32
|
declare function loadDiffConfig(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<SerializedDiffOptions | undefined>;
|
|
33
33
|
declare function loadSnapshotSerializers(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<void>;
|
|
34
34
|
|
|
35
|
+
interface FsOptions {
|
|
36
|
+
encoding?: BufferEncoding;
|
|
37
|
+
flag?: string | number;
|
|
38
|
+
}
|
|
39
|
+
interface BrowserCommands {
|
|
40
|
+
readFile: (path: string, options?: BufferEncoding | FsOptions) => Promise<string>;
|
|
41
|
+
writeFile: (path: string, content: string, options?: BufferEncoding | (FsOptions & {
|
|
42
|
+
mode?: number | string;
|
|
43
|
+
})) => Promise<void>;
|
|
44
|
+
removeFile: (path: string) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
export { loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
|
|
48
|
+
export type { BrowserCommands, FsOptions };
|
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.
|
|
1
|
+
export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.DgXU7Yho.js';
|
|
2
2
|
export { collectTests, startTests } from '@vitest/runner';
|
|
3
3
|
import * as spyModule from '@vitest/spy';
|
|
4
4
|
export { spyModule as SpyModule };
|
|
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
|
|
|
3
3
|
import { normalize } from 'pathe';
|
|
4
4
|
import c from 'tinyrainbow';
|
|
5
5
|
import { a as defaultPort, d as defaultBrowserPort } from './constants.D_Q9UYh-.js';
|
|
6
|
-
import { R as ReportersMap } from './index.
|
|
6
|
+
import { R as ReportersMap } from './index.D2gVI9Ck.js';
|
|
7
7
|
|
|
8
8
|
function toArr(any) {
|
|
9
9
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -619,7 +619,7 @@ class CAC extends EventEmitter {
|
|
|
619
619
|
|
|
620
620
|
const cac = (name = "") => new CAC(name);
|
|
621
621
|
|
|
622
|
-
var version = "4.0.0-beta.
|
|
622
|
+
var version = "4.0.0-beta.18";
|
|
623
623
|
|
|
624
624
|
const apiConfig = (port) => ({
|
|
625
625
|
port: {
|
|
@@ -1341,22 +1341,22 @@ function normalizeCliOptions(cliFilters, argv) {
|
|
|
1341
1341
|
}
|
|
1342
1342
|
async function start(mode, cliFilters, options) {
|
|
1343
1343
|
try {
|
|
1344
|
-
const { startVitest } = await import('./cli-api.
|
|
1344
|
+
const { startVitest } = await import('./cli-api.xhe4uqTX.js').then(function (n) { return n.h; }), ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
1345
1345
|
if (!ctx.shouldKeepServer()) await ctx.exit();
|
|
1346
1346
|
} catch (e) {
|
|
1347
|
-
const { errorBanner } = await import('./index.
|
|
1347
|
+
const { errorBanner } = await import('./index.D2gVI9Ck.js').then(function (n) { return n.u; });
|
|
1348
1348
|
if (console.error(`\n${errorBanner("Startup Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
|
|
1349
1349
|
process.exit();
|
|
1350
1350
|
}
|
|
1351
1351
|
}
|
|
1352
1352
|
async function init(project) {
|
|
1353
1353
|
if (project !== "browser") console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project.")), process.exit(1);
|
|
1354
|
-
const { create } = await import('./creator.
|
|
1354
|
+
const { create } = await import('./creator.DucAaYBz.js');
|
|
1355
1355
|
await create();
|
|
1356
1356
|
}
|
|
1357
1357
|
async function collect(mode, cliFilters, options) {
|
|
1358
1358
|
try {
|
|
1359
|
-
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.
|
|
1359
|
+
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.xhe4uqTX.js').then(function (n) { return n.h; }), ctx = await prepareVitest(mode, {
|
|
1360
1360
|
...normalizeCliOptions(cliFilters, options),
|
|
1361
1361
|
watch: false,
|
|
1362
1362
|
run: true
|
|
@@ -1374,7 +1374,7 @@ async function collect(mode, cliFilters, options) {
|
|
|
1374
1374
|
}
|
|
1375
1375
|
await ctx.close();
|
|
1376
1376
|
} catch (e) {
|
|
1377
|
-
const { errorBanner } = await import('./index.
|
|
1377
|
+
const { errorBanner } = await import('./index.D2gVI9Ck.js').then(function (n) { return n.u; });
|
|
1378
1378
|
if (console.error(`\n${errorBanner("Collect Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
|
|
1379
1379
|
process.exit();
|
|
1380
1380
|
}
|
|
@@ -10,7 +10,7 @@ import { A as API_PATH, c as configFiles, d as defaultBrowserPort, a as defaultP
|
|
|
10
10
|
import nodeos__default, { tmpdir } from 'node:os';
|
|
11
11
|
import { generateHash as generateHash$1, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, hasFailed, getTasks, isTestCase } from '@vitest/runner/utils';
|
|
12
12
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
13
|
-
import { v as version$1 } from './cac.
|
|
13
|
+
import { v as version$1 } from './cac.DYnuYoJK.js';
|
|
14
14
|
import { c as createBirpc } from './index.Bgo3tNWt.js';
|
|
15
15
|
import { p as parse, s as stringify, b as TraceMap, o as originalPositionFor, c as ancestor, d as createDefinesScript, e as convertTasksToEvents } from './typechecker.DsKAhua5.js';
|
|
16
16
|
import require$$0$3 from 'events';
|
|
@@ -26,17 +26,17 @@ import require$$0$1 from 'buffer';
|
|
|
26
26
|
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
27
27
|
import crypto, { createHash } from 'node:crypto';
|
|
28
28
|
import { distDir, rootDir } from '../path.js';
|
|
29
|
-
import { d as createDebugger, h as hash, e as createFetchModuleFunction, n as normalizeResolvedIdToUrl, R as RandomSequencer, i as isPackageExists, g as getFilePoolName, f as isBrowserEnabled, r as resolveConfig, j as groupBy, k as getCoverageProvider, l as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.
|
|
29
|
+
import { d as createDebugger, h as hash, e as createFetchModuleFunction, n as normalizeResolvedIdToUrl, R as RandomSequencer, i as isPackageExists, g as getFilePoolName, f as isBrowserEnabled, r as resolveConfig, j as groupBy, k as getCoverageProvider, l as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.Ds84cgzV.js';
|
|
30
30
|
import { VitestModuleEvaluator } from '#module-evaluator';
|
|
31
31
|
import { ModuleRunner } from 'vite/module-runner';
|
|
32
32
|
import { Console } from 'node:console';
|
|
33
33
|
import c from 'tinyrainbow';
|
|
34
34
|
import { highlight } from '@vitest/utils/highlight';
|
|
35
|
-
import { p as printError, f as formatProjectName, w as withLabel, e as errorBanner, d as divider, h as generateCodeFrame, R as ReportersMap, B as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.
|
|
35
|
+
import { p as printError, f as formatProjectName, w as withLabel, e as errorBanner, d as divider, h as generateCodeFrame, R as ReportersMap, B as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.D2gVI9Ck.js';
|
|
36
36
|
import { createRequire, builtinModules, isBuiltin } from 'node:module';
|
|
37
37
|
import url, { pathToFileURL } from 'node:url';
|
|
38
38
|
import { i as isTTY, a as isWindows } from './env.D4Lgay0q.js';
|
|
39
|
-
import { rm, mkdir, copyFile } from 'node:fs/promises';
|
|
39
|
+
import { rm, writeFile, mkdir, copyFile } from 'node:fs/promises';
|
|
40
40
|
import pm from 'picomatch';
|
|
41
41
|
import { glob, isDynamicPattern } from 'tinyglobby';
|
|
42
42
|
import MagicString from 'magic-string';
|
|
@@ -45,7 +45,7 @@ import { c as configDefaults } from './defaults.CXFFjsi8.js';
|
|
|
45
45
|
import { KNOWN_ASSET_RE } from '@vitest/utils/constants';
|
|
46
46
|
import { findNearestPackageData } from '@vitest/utils/resolver';
|
|
47
47
|
import * as esModuleLexer from 'es-module-lexer';
|
|
48
|
-
import { a as BenchmarkReportsMap } from './index.
|
|
48
|
+
import { a as BenchmarkReportsMap } from './index.eEkl9h8v.js';
|
|
49
49
|
import assert$1 from 'node:assert';
|
|
50
50
|
import { serializeValue } from '@vitest/utils/serialize';
|
|
51
51
|
import { parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
@@ -7112,7 +7112,6 @@ async function createViteServer(inlineConfig) {
|
|
|
7112
7112
|
class TestProject {
|
|
7113
7113
|
/**
|
|
7114
7114
|
* The global Vitest instance.
|
|
7115
|
-
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
7116
7115
|
*/
|
|
7117
7116
|
vitest;
|
|
7118
7117
|
/**
|
|
@@ -8208,6 +8207,7 @@ class StateManager {
|
|
|
8208
8207
|
reportedTasksMap = /* @__PURE__ */ new WeakMap();
|
|
8209
8208
|
blobs;
|
|
8210
8209
|
transformTime = 0;
|
|
8210
|
+
metadata = {};
|
|
8211
8211
|
onUnhandledError;
|
|
8212
8212
|
/** @internal */
|
|
8213
8213
|
_data = {
|
|
@@ -8825,7 +8825,15 @@ class TestRun {
|
|
|
8825
8825
|
// specification won't have the File task if they were filtered by the --shard command
|
|
8826
8826
|
const modules = specifications.map((spec) => spec.testModule).filter((s) => s != null), state = this.vitest.isCancelling ? "interrupted" : this.hasFailed(modules) ? "failed" : "passed";
|
|
8827
8827
|
if (state !== "passed") process.exitCode = 1;
|
|
8828
|
-
await this.vitest.report("onTestRunEnd", modules, [...errors], state)
|
|
8828
|
+
for (const project in await this.vitest.report("onTestRunEnd", modules, [...errors], state), this.vitest.state.metadata) {
|
|
8829
|
+
const meta = this.vitest.state.metadata[project];
|
|
8830
|
+
if (!meta?.dumpDir) continue;
|
|
8831
|
+
const path = resolve(meta.dumpDir, "vitest-metadata.json");
|
|
8832
|
+
meta.outline = {
|
|
8833
|
+
externalized: Object.keys(meta.externalized).length,
|
|
8834
|
+
inlined: Object.keys(meta.tmps).length
|
|
8835
|
+
}, await writeFile(path, JSON.stringify(meta, null, 2), "utf-8"), this.vitest.logger.log(`Metadata written to ${path}`);
|
|
8836
|
+
}
|
|
8829
8837
|
}
|
|
8830
8838
|
hasFailed(modules) {
|
|
8831
8839
|
return modules.length ? modules.some((m) => !m.ok()) : !this.vitest.config.passWithNoTests;
|
|
@@ -213,4 +213,4 @@ type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookT
|
|
|
213
213
|
type RuntimeOptions = Partial<RuntimeConfig>;
|
|
214
214
|
type BrowserTraceViewMode = "on" | "off" | "on-first-retry" | "on-all-retries" | "retain-on-failure";
|
|
215
215
|
|
|
216
|
-
export type { BrowserTraceViewMode as B, FakeTimerInstallOpts as F, RuntimeOptions as R,
|
|
216
|
+
export type { BrowserTraceViewMode as B, FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedConfig as S, SerializedCoverageConfig as a, RuntimeConfig as b };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs, { statSync, realpathSync, promises as promises$1, mkdirSync, existsSync, readdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import path, { win32, dirname, join, resolve } from 'node:path';
|
|
2
|
+
import path, { win32, dirname, join, resolve as resolve$1 } from 'node:path';
|
|
3
3
|
import { createDefer, isExternalUrl, unwrapId, nanoid, withTrailingSlash as withTrailingSlash$1, cleanUrl, wrapId, slash, shuffle, toArray } from '@vitest/utils/helpers';
|
|
4
|
-
import { isAbsolute, join as join$1, dirname as dirname$1, resolve
|
|
4
|
+
import { isAbsolute, join as join$1, dirname as dirname$1, resolve, relative, normalize } from 'pathe';
|
|
5
5
|
import pm from 'picomatch';
|
|
6
6
|
import { glob } from 'tinyglobby';
|
|
7
7
|
import c from 'tinyrainbow';
|
|
@@ -9,7 +9,7 @@ import { c as configDefaults, e as benchmarkConfigDefaults, a as coverageConfigD
|
|
|
9
9
|
import crypto from 'node:crypto';
|
|
10
10
|
import { builtinModules, createRequire } from 'node:module';
|
|
11
11
|
import process$1 from 'node:process';
|
|
12
|
-
import fs$1, { writeFile, rename, stat, unlink } from 'node:fs/promises';
|
|
12
|
+
import fs$1, { writeFile, rename, stat, unlink, readFile as readFile$1 } from 'node:fs/promises';
|
|
13
13
|
import { fileURLToPath as fileURLToPath$1, pathToFileURL as pathToFileURL$1, URL as URL$1 } from 'node:url';
|
|
14
14
|
import assert from 'node:assert';
|
|
15
15
|
import v8 from 'node:v8';
|
|
@@ -2602,7 +2602,7 @@ async function groupFilesByEnv(files) {
|
|
|
2602
2602
|
}
|
|
2603
2603
|
|
|
2604
2604
|
const created = /* @__PURE__ */ new Set(), promises = /* @__PURE__ */ new Map();
|
|
2605
|
-
function createFetchModuleFunction(resolver, cacheFs = false, tmpDir = join$1(tmpdir(), nanoid())) {
|
|
2605
|
+
function createFetchModuleFunction(resolver, cacheFs = false, tmpDir = join$1(tmpdir(), nanoid()), dump) {
|
|
2606
2606
|
const cachedFsResults = /* @__PURE__ */ new Map();
|
|
2607
2607
|
return async (url, importer, environment, options) => {
|
|
2608
2608
|
// We are copy pasting Vite's externalization logic from `fetchModule` because
|
|
@@ -2637,10 +2637,35 @@ function createFetchModuleFunction(resolver, cacheFs = false, tmpDir = join$1(tm
|
|
|
2637
2637
|
type: "module"
|
|
2638
2638
|
};
|
|
2639
2639
|
}
|
|
2640
|
-
|
|
2640
|
+
let moduleRunnerModule;
|
|
2641
|
+
if (dump?.dumpFolder && dump.readFromDump) {
|
|
2642
|
+
const path = resolve(dump?.dumpFolder, url.replace(/[^\w+]/g, "-"));
|
|
2643
|
+
if (existsSync(path)) {
|
|
2644
|
+
const code = await readFile$1(path, "utf-8"), matchIndex = code.lastIndexOf("\n//");
|
|
2645
|
+
if (matchIndex !== -1) {
|
|
2646
|
+
const { id, file } = JSON.parse(code.slice(matchIndex + 4));
|
|
2647
|
+
moduleRunnerModule = {
|
|
2648
|
+
code,
|
|
2649
|
+
id,
|
|
2650
|
+
url,
|
|
2651
|
+
file,
|
|
2652
|
+
invalidate: false
|
|
2653
|
+
};
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
if (!moduleRunnerModule) moduleRunnerModule = await fetchModule(environment, url, importer, {
|
|
2641
2658
|
...options,
|
|
2642
2659
|
inlineSourceMap: false
|
|
2643
|
-
}).catch(handleRollupError)
|
|
2660
|
+
}).catch(handleRollupError);
|
|
2661
|
+
const result = processResultSource(environment, moduleRunnerModule);
|
|
2662
|
+
if (dump?.dumpFolder && "code" in result) {
|
|
2663
|
+
const path = resolve(dump?.dumpFolder, result.url.replace(/[^\w+]/g, "-"));
|
|
2664
|
+
await writeFile(path, `${result.code}\n// ${JSON.stringify({
|
|
2665
|
+
id: result.id,
|
|
2666
|
+
file: result.file
|
|
2667
|
+
})}`, "utf-8");
|
|
2668
|
+
}
|
|
2644
2669
|
if (!cacheFs || !("code" in result)) return result;
|
|
2645
2670
|
const code = result.code;
|
|
2646
2671
|
// to avoid serialising large chunks of code,
|
|
@@ -2760,17 +2785,30 @@ function normalizeResolvedIdToUrl(environment, resolvedId) {
|
|
|
2760
2785
|
}
|
|
2761
2786
|
|
|
2762
2787
|
function createMethodsRPC(project, options = {}) {
|
|
2763
|
-
const
|
|
2788
|
+
const vitest = project.vitest, cacheFs = options.cacheFs ?? false;
|
|
2789
|
+
if (project.vitest.state.metadata[project.name] ??= {
|
|
2790
|
+
externalized: {},
|
|
2791
|
+
duration: {},
|
|
2792
|
+
tmps: {}
|
|
2793
|
+
}, project.config.dumpDir && !existsSync(project.config.dumpDir)) mkdirSync(project.config.dumpDir, { recursive: true });
|
|
2794
|
+
project.vitest.state.metadata[project.name].dumpDir = project.config.dumpDir;
|
|
2795
|
+
const fetch = createFetchModuleFunction(project._resolver, cacheFs, project.tmpDir, {
|
|
2796
|
+
dumpFolder: project.config.dumpDir,
|
|
2797
|
+
readFromDump: project.config.server.debug?.load ?? process.env.VITEST_DEBUG_LOAD_DUMP != null
|
|
2798
|
+
});
|
|
2764
2799
|
return {
|
|
2765
2800
|
async fetch(url, importer, environmentName, options) {
|
|
2766
2801
|
const environment = project.vite.environments[environmentName];
|
|
2767
2802
|
if (!environment) throw new Error(`The environment ${environmentName} was not defined in the Vite config.`);
|
|
2768
2803
|
const start = performance.now();
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
project.vitest.state.
|
|
2773
|
-
|
|
2804
|
+
return await fetch(url, importer, environment, options).then((result) => {
|
|
2805
|
+
const duration = performance.now() - start;
|
|
2806
|
+
project.vitest.state.transformTime += duration;
|
|
2807
|
+
const metadata = project.vitest.state.metadata[project.name];
|
|
2808
|
+
if ("externalize" in result) metadata.externalized[url] = result.externalize;
|
|
2809
|
+
if ("tmp" in result) metadata.tmps[url] = result.tmp;
|
|
2810
|
+
return metadata.duration[url] ??= [], metadata.duration[url].push(duration), result;
|
|
2811
|
+
});
|
|
2774
2812
|
},
|
|
2775
2813
|
async resolve(id, importer, environmentName) {
|
|
2776
2814
|
const environment = project.vite.environments[environmentName];
|
|
@@ -2783,10 +2821,10 @@ function createMethodsRPC(project, options = {}) {
|
|
|
2783
2821
|
} : null;
|
|
2784
2822
|
},
|
|
2785
2823
|
snapshotSaved(snapshot) {
|
|
2786
|
-
|
|
2824
|
+
vitest.snapshot.add(snapshot);
|
|
2787
2825
|
},
|
|
2788
2826
|
resolveSnapshotPath(testPath) {
|
|
2789
|
-
return
|
|
2827
|
+
return vitest.snapshot.resolvePath(testPath, { config: project.serializedConfig });
|
|
2790
2828
|
},
|
|
2791
2829
|
async transform(id) {
|
|
2792
2830
|
const environment = project.vite.environments.__vitest_vm__;
|
|
@@ -2795,35 +2833,35 @@ function createMethodsRPC(project, options = {}) {
|
|
|
2795
2833
|
return { code: (await environment.transformRequest(url).catch(handleRollupError))?.code };
|
|
2796
2834
|
},
|
|
2797
2835
|
async onQueued(file) {
|
|
2798
|
-
if (options.collect)
|
|
2799
|
-
else await
|
|
2836
|
+
if (options.collect) vitest.state.collectFiles(project, [file]);
|
|
2837
|
+
else await vitest._testRun.enqueued(project, file);
|
|
2800
2838
|
},
|
|
2801
2839
|
async onCollected(files) {
|
|
2802
|
-
if (options.collect)
|
|
2803
|
-
else await
|
|
2840
|
+
if (options.collect) vitest.state.collectFiles(project, files);
|
|
2841
|
+
else await vitest._testRun.collected(project, files);
|
|
2804
2842
|
},
|
|
2805
2843
|
onAfterSuiteRun(meta) {
|
|
2806
|
-
|
|
2844
|
+
vitest.coverageProvider?.onAfterSuiteRun(meta);
|
|
2807
2845
|
},
|
|
2808
2846
|
async onTaskAnnotate(testId, annotation) {
|
|
2809
|
-
return
|
|
2847
|
+
return vitest._testRun.annotate(testId, annotation);
|
|
2810
2848
|
},
|
|
2811
2849
|
async onTaskUpdate(packs, events) {
|
|
2812
|
-
if (options.collect)
|
|
2813
|
-
else await
|
|
2850
|
+
if (options.collect) vitest.state.updateTasks(packs);
|
|
2851
|
+
else await vitest._testRun.updated(packs, events);
|
|
2814
2852
|
},
|
|
2815
2853
|
async onUserConsoleLog(log) {
|
|
2816
|
-
if (options.collect)
|
|
2817
|
-
else await
|
|
2854
|
+
if (options.collect) vitest.state.updateUserLog(log);
|
|
2855
|
+
else await vitest._testRun.log(log);
|
|
2818
2856
|
},
|
|
2819
2857
|
onUnhandledError(err, type) {
|
|
2820
|
-
|
|
2858
|
+
vitest.state.catchError(err, type);
|
|
2821
2859
|
},
|
|
2822
2860
|
onCancel(reason) {
|
|
2823
|
-
|
|
2861
|
+
vitest.cancelCurrentRun(reason);
|
|
2824
2862
|
},
|
|
2825
2863
|
getCountOfFailedTests() {
|
|
2826
|
-
return
|
|
2864
|
+
return vitest.state.getCountOfFailedTests();
|
|
2827
2865
|
}
|
|
2828
2866
|
};
|
|
2829
2867
|
}
|
|
@@ -2868,7 +2906,7 @@ function createChildProcessChannel$1(project, collect = false) {
|
|
|
2868
2906
|
function createForksPool(vitest, { execArgv, env }, specifications) {
|
|
2869
2907
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length, threadsCount = vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1), recommendedCount = vitest.config.watch ? threadsCount : Math.min(threadsCount, specifications.length), poolOptions = vitest.config.poolOptions?.forks ?? {}, maxThreads = poolOptions.maxForks ?? vitest.config.maxWorkers ?? recommendedCount, minThreads = vitest.config.watch ? Math.min(recommendedCount, maxThreads) : 0, options = {
|
|
2870
2908
|
runtime: "child_process",
|
|
2871
|
-
filename: resolve(vitest.distPath, "worker-base.js"),
|
|
2909
|
+
filename: resolve$1(vitest.distPath, "worker-base.js"),
|
|
2872
2910
|
teardown: "teardown",
|
|
2873
2911
|
maxThreads,
|
|
2874
2912
|
minThreads,
|
|
@@ -2971,7 +3009,7 @@ function createWorkerChannel$1(project, collect) {
|
|
|
2971
3009
|
}
|
|
2972
3010
|
function createThreadsPool(vitest, { execArgv, env }, specifications) {
|
|
2973
3011
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length, threadsCount = vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1), recommendedCount = vitest.config.watch ? threadsCount : Math.min(threadsCount, specifications.length), poolOptions = vitest.config.poolOptions?.threads ?? {}, maxThreads = poolOptions.maxThreads ?? vitest.config.maxWorkers ?? recommendedCount, minThreads = vitest.config.watch ? Math.min(recommendedCount, maxThreads) : 0, options = {
|
|
2974
|
-
filename: resolve(vitest.distPath, "worker-base.js"),
|
|
3012
|
+
filename: resolve$1(vitest.distPath, "worker-base.js"),
|
|
2975
3013
|
teardown: "teardown",
|
|
2976
3014
|
useAtomics: poolOptions.useAtomics ?? false,
|
|
2977
3015
|
maxThreads,
|
|
@@ -3222,7 +3260,7 @@ function createChildProcessChannel(project, collect) {
|
|
|
3222
3260
|
function createVmForksPool(vitest, { execArgv, env }, specifications) {
|
|
3223
3261
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length, threadsCount = vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1), recommendedCount = vitest.config.watch ? threadsCount : Math.min(threadsCount, specifications.length), poolOptions = vitest.config.poolOptions?.vmForks ?? {}, maxThreads = poolOptions.maxForks ?? vitest.config.maxWorkers ?? recommendedCount, minThreads = vitest.config.watch ? Math.min(recommendedCount, maxThreads) : 0, options = {
|
|
3224
3262
|
runtime: "child_process",
|
|
3225
|
-
filename: resolve(vitest.distPath, "worker-vm.js"),
|
|
3263
|
+
filename: resolve$1(vitest.distPath, "worker-vm.js"),
|
|
3226
3264
|
maxThreads,
|
|
3227
3265
|
minThreads,
|
|
3228
3266
|
env,
|
|
@@ -3311,7 +3349,7 @@ function createWorkerChannel(project, collect) {
|
|
|
3311
3349
|
}
|
|
3312
3350
|
function createVmThreadsPool(vitest, { execArgv, env }, specifications) {
|
|
3313
3351
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length, threadsCount = vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1), recommendedCount = vitest.config.watch ? threadsCount : Math.min(threadsCount, specifications.length), poolOptions = vitest.config.poolOptions?.vmThreads ?? {}, maxThreads = poolOptions.maxThreads ?? vitest.config.maxWorkers ?? recommendedCount, minThreads = vitest.config.watch ? Math.min(recommendedCount, maxThreads) : 0, options = {
|
|
3314
|
-
filename: resolve(vitest.distPath, "worker-vm.js"),
|
|
3352
|
+
filename: resolve$1(vitest.distPath, "worker-vm.js"),
|
|
3315
3353
|
useAtomics: poolOptions.useAtomics ?? false,
|
|
3316
3354
|
maxThreads,
|
|
3317
3355
|
minThreads,
|
|
@@ -3380,7 +3418,7 @@ function getMemoryLimit(config) {
|
|
|
3380
3418
|
return typeof memory === "number" ? stringToBytes(limit, config.watch ? memory / 2 : memory) : typeof limit === "number" && limit > 1 || typeof limit === "string" && limit.at(-1) !== "%" ? stringToBytes(limit) : null;
|
|
3381
3419
|
}
|
|
3382
3420
|
|
|
3383
|
-
const suppressWarningsPath = resolve
|
|
3421
|
+
const suppressWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
|
|
3384
3422
|
const builtinPools = [
|
|
3385
3423
|
"forks",
|
|
3386
3424
|
"threads",
|
|
@@ -3519,7 +3557,7 @@ class BaseSequencer {
|
|
|
3519
3557
|
async shard(files) {
|
|
3520
3558
|
const { config } = this.ctx, { index, count } = config.shard, [shardStart, shardEnd] = this.calculateShardRange(files.length, index, count);
|
|
3521
3559
|
return [...files].map((spec) => {
|
|
3522
|
-
const specPath = resolve
|
|
3560
|
+
const specPath = resolve(slash(config.root), slash(spec.moduleId))?.slice(config.root.length);
|
|
3523
3561
|
return {
|
|
3524
3562
|
spec,
|
|
3525
3563
|
hash: hash("sha1", specPath, "hex")
|
|
@@ -3560,7 +3598,7 @@ class RandomSequencer extends BaseSequencer {
|
|
|
3560
3598
|
}
|
|
3561
3599
|
|
|
3562
3600
|
function resolvePath(path, root) {
|
|
3563
|
-
return normalize(/* @__PURE__ */ resolveModule(path, { paths: [root] }) ?? resolve
|
|
3601
|
+
return normalize(/* @__PURE__ */ resolveModule(path, { paths: [root] }) ?? resolve(root, path));
|
|
3564
3602
|
}
|
|
3565
3603
|
function parseInspector(inspect) {
|
|
3566
3604
|
if (typeof inspect === "boolean" || inspect === void 0) return {};
|
|
@@ -3691,7 +3729,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
3691
3729
|
}
|
|
3692
3730
|
}
|
|
3693
3731
|
if (resolved.coverage.reporter = resolveCoverageReporters(resolved.coverage.reporter), resolved.coverage.enabled && resolved.coverage.reportsDirectory) {
|
|
3694
|
-
const reportsDirectory = resolve
|
|
3732
|
+
const reportsDirectory = resolve(resolved.root, resolved.coverage.reportsDirectory);
|
|
3695
3733
|
if (reportsDirectory === resolved.root || reportsDirectory === process.cwd()) throw new Error(`You cannot set "coverage.reportsDirectory" as ${reportsDirectory}. Vitest needs to be able to remove this directory before test run`);
|
|
3696
3734
|
}
|
|
3697
3735
|
if (resolved.coverage.enabled && resolved.coverage.provider === "custom" && resolved.coverage.customProviderModule) resolved.coverage.customProviderModule = resolvePath(resolved.coverage.customProviderModule, resolved.root);
|
|
@@ -3714,7 +3752,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
3714
3752
|
"**/node_modules/**"
|
|
3715
3753
|
].filter((pattern) => pattern != null), resolved.forceRerunTriggers = [...resolved.forceRerunTriggers, ...resolved.setupFiles], resolved.cliExclude) resolved.exclude.push(...resolved.cliExclude);
|
|
3716
3754
|
if (resolved.runner) resolved.runner = resolvePath(resolved.runner, resolved.root);
|
|
3717
|
-
if (resolved.attachmentsDir = resolve
|
|
3755
|
+
if (resolved.attachmentsDir = resolve(resolved.root, resolved.attachmentsDir ?? ".vitest-attachments"), resolved.snapshotEnvironment) resolved.snapshotEnvironment = resolvePath(resolved.snapshotEnvironment, resolved.root);
|
|
3718
3756
|
if (resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0, resolved.snapshotFormat && "plugins" in resolved.snapshotFormat) {
|
|
3719
3757
|
// TODO: support it via separate config (like DiffOptions) or via `Function.toString()`
|
|
3720
3758
|
if (resolved.snapshotFormat.plugins = [], typeof resolved.snapshotFormat.compareKeys === "function") throw new TypeError(`"snapshotFormat.compareKeys" function is not supported.`);
|
|
@@ -3769,7 +3807,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
3769
3807
|
if (resolved.api = {
|
|
3770
3808
|
...resolveApiServerConfig(options, defaultPort),
|
|
3771
3809
|
token: crypto.randomUUID()
|
|
3772
|
-
}, options.related) resolved.related = toArray(options.related).map((file) => resolve
|
|
3810
|
+
}, options.related) resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
|
|
3773
3811
|
/*
|
|
3774
3812
|
* Reporters can be defined in many different ways:
|
|
3775
3813
|
* { reporter: 'json' }
|
|
@@ -3799,7 +3837,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
3799
3837
|
// @ts-expect-error "reporter" is from CLI, should be absolute to the running directory
|
|
3800
3838
|
// it is passed down as "vitest --reporter ../reporter.js"
|
|
3801
3839
|
const reportersFromCLI = resolved.reporter, cliReporters = toArray(reportersFromCLI || []).map((reporter) => {
|
|
3802
|
-
return /^\.\.?\//.test(reporter) ? resolve
|
|
3840
|
+
return /^\.\.?\//.test(reporter) ? resolve(process.cwd(), reporter) : reporter;
|
|
3803
3841
|
});
|
|
3804
3842
|
if (cliReporters.length) resolved.reporters = Array.from(new Set(toArray(cliReporters))).filter(Boolean).map((reporter) => [reporter, {}]);
|
|
3805
3843
|
}
|
|
@@ -3825,7 +3863,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
3825
3863
|
...configDefaults.typecheck,
|
|
3826
3864
|
...resolved.typecheck
|
|
3827
3865
|
}, resolved.typecheck ??= {}, resolved.typecheck.enabled ??= false, resolved.typecheck.enabled) logger.console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
|
|
3828
|
-
if (resolved.browser.enabled ??= false, resolved.browser.headless ??= isCI, resolved.browser.isolate ??= true, resolved.browser.fileParallelism ??= options.fileParallelism ?? mode !== "benchmark", resolved.browser.ui ??= resolved.browser.headless === true ? false : !isCI, resolved.browser.commands ??= {}, resolved.browser.screenshotDirectory) resolved.browser.screenshotDirectory = resolve
|
|
3866
|
+
if (resolved.browser.enabled ??= false, resolved.browser.headless ??= isCI, resolved.browser.isolate ??= true, resolved.browser.fileParallelism ??= options.fileParallelism ?? mode !== "benchmark", resolved.browser.ui ??= resolved.browser.headless === true ? false : !isCI, resolved.browser.commands ??= {}, resolved.browser.screenshotDirectory) resolved.browser.screenshotDirectory = resolve(resolved.root, resolved.browser.screenshotDirectory);
|
|
3829
3867
|
if (resolved.browser.viewport ??= {}, resolved.browser.viewport.width ??= 414, resolved.browser.viewport.height ??= 896, resolved.browser.locators ??= {}, resolved.browser.locators.testIdAttribute ??= "data-testid", typeof resolved.browser.provider === "string") {
|
|
3830
3868
|
const source = `@vitest/browser-${resolved.browser.provider}`;
|
|
3831
3869
|
throw new TypeError(`The \`browser.provider\` configuration was changed to accept a factory instead of a string. Add an import of "${resolved.browser.provider}" from "${source}" instead. See: https://vitest.dev/guide/browser/config#provider`);
|
|
@@ -3848,7 +3886,11 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
3848
3886
|
if (toArray(resolved.reporters).some((reporter) => {
|
|
3849
3887
|
return Array.isArray(reporter) ? reporter[0] === "html" : false;
|
|
3850
3888
|
})) resolved.includeTaskLocation ??= true;
|
|
3851
|
-
|
|
3889
|
+
if (resolved.server ??= {}, resolved.server.deps ??= {}, resolved.server.debug?.dump || process.env.VITEST_DEBUG_DUMP) {
|
|
3890
|
+
const userFolder = resolved.server.debug?.dump || process.env.VITEST_DEBUG_DUMP;
|
|
3891
|
+
resolved.dumpDir = resolve(resolved.root, typeof userFolder === "string" && userFolder !== "true" ? userFolder : ".vitest-dump", resolved.name || "root");
|
|
3892
|
+
}
|
|
3893
|
+
return resolved.testTimeout ??= resolved.browser.enabled ? 15e3 : 5e3, resolved.hookTimeout ??= resolved.browser.enabled ? 3e4 : 1e4, resolved;
|
|
3852
3894
|
}
|
|
3853
3895
|
function isBrowserEnabled(config) {
|
|
3854
3896
|
return Boolean(config.browser?.enabled);
|
|
@@ -3913,7 +3955,7 @@ Update your dependencies and make sure the versions match.`));
|
|
|
3913
3955
|
...coverageConfigDefaults,
|
|
3914
3956
|
...config,
|
|
3915
3957
|
provider: this.name,
|
|
3916
|
-
reportsDirectory: resolve
|
|
3958
|
+
reportsDirectory: resolve(ctx.config.root, config.reportsDirectory || coverageConfigDefaults.reportsDirectory),
|
|
3917
3959
|
reporter: resolveCoverageReporters(config.reporter || coverageConfigDefaults.reporter),
|
|
3918
3960
|
thresholds: config.thresholds && {
|
|
3919
3961
|
...config.thresholds,
|
|
@@ -3925,7 +3967,7 @@ Update your dependencies and make sure the versions match.`));
|
|
|
3925
3967
|
};
|
|
3926
3968
|
const shard = this.ctx.config.shard, tempDirectory = `.tmp${shard ? `-${shard.index}-${shard.count}` : ""}`;
|
|
3927
3969
|
// If --project filter is set pick only roots of resolved projects
|
|
3928
|
-
this.coverageFilesDirectory = resolve
|
|
3970
|
+
this.coverageFilesDirectory = resolve(this.options.reportsDirectory, tempDirectory), this.roots = ctx.config.project?.length ? [...new Set(ctx.projects.map((project) => project.config.root))] : [ctx.config.root];
|
|
3929
3971
|
}
|
|
3930
3972
|
/**
|
|
3931
3973
|
* Check if file matches `coverage.include` but not `coverage.exclude`
|
|
@@ -3993,7 +4035,7 @@ Update your dependencies and make sure the versions match.`));
|
|
|
3993
4035
|
if (!coverage) return;
|
|
3994
4036
|
let entry = this.coverageFiles.get(projectName || DEFAULT_PROJECT);
|
|
3995
4037
|
if (!entry) entry = {}, this.coverageFiles.set(projectName || DEFAULT_PROJECT, entry);
|
|
3996
|
-
const testFilenames = testFiles.join(), filename = resolve
|
|
4038
|
+
const testFilenames = testFiles.join(), filename = resolve(this.coverageFilesDirectory, `coverage-${uniqueId++}.json`);
|
|
3997
4039
|
// If there's a result from previous run, overwrite it
|
|
3998
4040
|
entry[environment] ??= {}, entry[environment][testFilenames] = filename;
|
|
3999
4041
|
const promise = promises$1.writeFile(filename, JSON.stringify(coverage), "utf-8");
|
|
@@ -39,7 +39,7 @@ import { render } from '@testing-library/jsx'
|
|
|
39
39
|
import HelloWorld from './HelloWorld.jsx'
|
|
40
40
|
|
|
41
41
|
test('renders name', async () => {
|
|
42
|
-
const { getByText } = render(<HelloWorld name="Vitest" />)
|
|
42
|
+
const { getByText } = await render(<HelloWorld name="Vitest" />)
|
|
43
43
|
await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
|
|
44
44
|
})
|
|
45
45
|
`
|
|
@@ -2,7 +2,7 @@ import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
|
|
|
2
2
|
import { Plugin } from '@vitest/pretty-format';
|
|
3
3
|
import { SnapshotState } from '@vitest/snapshot';
|
|
4
4
|
import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
|
|
5
|
-
import { U as UserConsoleLog } from './worker.d.
|
|
5
|
+
import { U as UserConsoleLog } from './worker.d.DSgBAZPX.js';
|
|
6
6
|
|
|
7
7
|
interface SnapshotMatcher<T> {
|
|
8
8
|
<U extends { [P in keyof T] : any }>(snapshot: Partial<U>, hint?: string): void;
|
|
@@ -23,6 +23,7 @@ declare module "@vitest/expect" {
|
|
|
23
23
|
message?: string;
|
|
24
24
|
}
|
|
25
25
|
interface ExpectStatic {
|
|
26
|
+
assert: Chai.AssertStatic;
|
|
26
27
|
unreachable: (message?: string) => never;
|
|
27
28
|
soft: <T>(actual: T, message?: string) => Assertion<T>;
|
|
28
29
|
poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.D_Q9UYh-.js';
|
|
2
|
-
import { i as index } from './index.
|
|
3
|
-
import './vi.
|
|
2
|
+
import { i as index } from './index.Bcjk8TKX.js';
|
|
3
|
+
import './vi.BZvkKVkM.js';
|
|
4
4
|
import '@vitest/expect';
|
|
5
5
|
import '@vitest/runner';
|
|
6
6
|
import '@vitest/runner/utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, d as vitest } from './vi.
|
|
1
|
+
import { b as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, d as vitest } from './vi.BZvkKVkM.js';
|
|
2
2
|
import { b as bench } from './benchmark.DHKMYAts.js';
|
|
3
3
|
import { expectTypeOf } from 'expect-type';
|
|
4
4
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
@@ -391,7 +391,7 @@ var jsdom = {
|
|
|
391
391
|
userAgent,
|
|
392
392
|
...restOptions
|
|
393
393
|
});
|
|
394
|
-
const clearWindowErrors = catchWindowErrors(dom.window);
|
|
394
|
+
const clearAddEventListenerPatch = patchAddEventListener(dom.window), clearWindowErrors = catchWindowErrors(dom.window);
|
|
395
395
|
dom.window.Buffer = Buffer, dom.window.jsdom = dom;
|
|
396
396
|
for (const name of [
|
|
397
397
|
"structuredClone",
|
|
@@ -422,7 +422,7 @@ var jsdom = {
|
|
|
422
422
|
return dom.getInternalVMContext();
|
|
423
423
|
},
|
|
424
424
|
teardown() {
|
|
425
|
-
clearWindowErrors(), dom.window.close(), dom = void 0;
|
|
425
|
+
clearAddEventListenerPatch(), clearWindowErrors(), dom.window.close(), dom = void 0;
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
},
|
|
@@ -438,12 +438,37 @@ var jsdom = {
|
|
|
438
438
|
contentType,
|
|
439
439
|
userAgent,
|
|
440
440
|
...restOptions
|
|
441
|
-
}), { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true }), clearWindowErrors = catchWindowErrors(global);
|
|
441
|
+
}), clearAddEventListenerPatch = patchAddEventListener(dom.window), { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true }), clearWindowErrors = catchWindowErrors(global);
|
|
442
442
|
return global.jsdom = dom, { teardown(global) {
|
|
443
|
-
clearWindowErrors(), dom.window.close(), delete global.jsdom, keys.forEach((key) => delete global[key]), originals.forEach((v, k) => global[k] = v);
|
|
443
|
+
clearAddEventListenerPatch(), clearWindowErrors(), dom.window.close(), delete global.jsdom, keys.forEach((key) => delete global[key]), originals.forEach((v, k) => global[k] = v);
|
|
444
444
|
} };
|
|
445
445
|
}
|
|
446
446
|
};
|
|
447
|
+
function patchAddEventListener(window) {
|
|
448
|
+
const JSDOMAbortSignal = window.AbortSignal, JSDOMAbortController = window.AbortController, originalAddEventListener = window.EventTarget.prototype.addEventListener;
|
|
449
|
+
return window.EventTarget.prototype.addEventListener = function addEventListener(type, callback, options) {
|
|
450
|
+
if (typeof options === "object" && options.signal != null) {
|
|
451
|
+
const { signal,...otherOptions } = options;
|
|
452
|
+
// - this happens because AbortSignal is provided by Node.js,
|
|
453
|
+
// but jsdom APIs require jsdom's AbortSignal, while Node APIs
|
|
454
|
+
// (like fetch and Request) require a Node.js AbortSignal
|
|
455
|
+
// - disable narrow typing with "as any" because we need it later
|
|
456
|
+
if (!(signal instanceof JSDOMAbortSignal)) {
|
|
457
|
+
const jsdomCompatOptions = Object.create(null);
|
|
458
|
+
Object.assign(jsdomCompatOptions, otherOptions);
|
|
459
|
+
// use jsdom-native abort controller instead and forward the
|
|
460
|
+
// previous one with `addEventListener`
|
|
461
|
+
const jsdomAbortController = new JSDOMAbortController();
|
|
462
|
+
return signal.addEventListener("abort", () => {
|
|
463
|
+
jsdomAbortController.abort(signal.reason);
|
|
464
|
+
}), jsdomCompatOptions.signal = jsdomAbortController.signal, originalAddEventListener.call(this, type, callback, jsdomCompatOptions);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return originalAddEventListener.call(this, type, callback, options);
|
|
468
|
+
}, () => {
|
|
469
|
+
window.EventTarget.prototype.addEventListener = originalAddEventListener;
|
|
470
|
+
};
|
|
471
|
+
}
|
|
447
472
|
|
|
448
473
|
// some globals we do not want, either because deprecated or we set it ourselves
|
|
449
474
|
const denyList = new Set([
|
|
@@ -1255,7 +1255,7 @@ class GithubActionsReporter {
|
|
|
1255
1255
|
this.ctx = ctx;
|
|
1256
1256
|
}
|
|
1257
1257
|
onTestCaseAnnotate(testCase, annotation) {
|
|
1258
|
-
if (!annotation.location) return;
|
|
1258
|
+
if (!annotation.location || this.options.displayAnnotations === false) return;
|
|
1259
1259
|
const type = getTitle(annotation.type), formatted = formatMessage({
|
|
1260
1260
|
command: getType(annotation.type),
|
|
1261
1261
|
properties: {
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import c from 'tinyrainbow';
|
|
5
|
-
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.
|
|
5
|
+
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.D2gVI9Ck.js';
|
|
6
6
|
import { stripVTControlCharacters } from 'node:util';
|
|
7
7
|
import { notNullish } from '@vitest/utils/helpers';
|
|
8
8
|
|