@vitest/browser 3.0.4 → 3.0.6
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/context.d.ts +8 -8
- package/dist/client/.vite/manifest.json +2 -2
- package/dist/client/__vitest__/assets/index-BX_iUIjH.js +52 -0
- package/dist/client/__vitest__/assets/{index-DGgp9MUX.css → index-CV9H8iCm.css} +1 -1
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/{orchestrator-vOivV83Y.js → orchestrator-BR1Ueh0Q.js} +1 -0
- package/dist/client/__vitest_browser__/tester-oUsZBBvV.js +15478 -0
- package/dist/client/esm-client-injector.js +1 -0
- package/dist/client/orchestrator.html +1 -1
- package/dist/client/tester/tester.html +1 -1
- package/dist/client.js +6 -6
- package/dist/context.js +2 -2
- package/dist/{index--cbQOwRJ.js → index-D-kNWeee.js} +2 -2
- package/dist/index.d.ts +5 -7
- package/dist/index.js +23 -14
- package/dist/locators/index.js +2 -2
- package/dist/locators/playwright.js +2 -2
- package/dist/locators/preview.js +2 -2
- package/dist/locators/webdriverio.js +2 -2
- package/dist/{public-utils-DldpEzVw.js → public-utils-J4vwTaki.js} +100 -102
- package/dist/state.js +1 -1
- package/dist/utils.js +1 -1
- package/jest-dom.d.ts +1 -2
- package/package.json +14 -14
- package/dist/client/__vitest__/assets/index-aqqnYS46.js +0 -52
- package/dist/client/__vitest_browser__/tester-BbJOQDQr.js +0 -13875
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
{__VITEST_INJECTOR__}
|
|
27
27
|
{__VITEST_ERROR_CATCHER__}
|
|
28
28
|
{__VITEST_SCRIPTS__}
|
|
29
|
-
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-
|
|
29
|
+
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-BR1Ueh0Q.js"></script>
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
|
|
31
31
|
</head>
|
|
32
32
|
<body>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" href="{__VITEST_FAVICON__}" type="image/svg+xml">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Vitest Browser Tester</title>
|
|
8
|
-
<script type="module" crossorigin src="/__vitest_browser__/tester-
|
|
8
|
+
<script type="module" crossorigin src="/__vitest_browser__/tester-oUsZBBvV.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/dist/client.js
CHANGED
|
@@ -28,7 +28,7 @@ function createBirpc(functions, options) {
|
|
|
28
28
|
if (method === "$close")
|
|
29
29
|
return close;
|
|
30
30
|
if (method === "then" && !eventNames.includes("then") && !("then" in functions))
|
|
31
|
-
return
|
|
31
|
+
return void 0;
|
|
32
32
|
const sendEvent = (...args) => {
|
|
33
33
|
post(serialize({ m: method, a: args, t: "q" }));
|
|
34
34
|
};
|
|
@@ -43,7 +43,7 @@ function createBirpc(functions, options) {
|
|
|
43
43
|
try {
|
|
44
44
|
await _promise;
|
|
45
45
|
} finally {
|
|
46
|
-
_promise =
|
|
46
|
+
_promise = void 0;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return new Promise((resolve, reject) => {
|
|
@@ -201,9 +201,9 @@ const parse = (text, reviver) => {
|
|
|
201
201
|
* @returns {string}
|
|
202
202
|
*/
|
|
203
203
|
const stringify = (value, replacer, space) => {
|
|
204
|
-
const $ = typeof replacer === object ?
|
|
205
|
-
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v :
|
|
206
|
-
(replacer);
|
|
204
|
+
const $ = replacer && typeof replacer === object ?
|
|
205
|
+
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
|
|
206
|
+
(replacer || noop);
|
|
207
207
|
const known = new Map;
|
|
208
208
|
const input = [];
|
|
209
209
|
const output = [];
|
|
@@ -258,7 +258,7 @@ const PORT = location.port;
|
|
|
258
258
|
const HOST = [location.hostname, PORT].filter(Boolean).join(":");
|
|
259
259
|
const RPC_ID = PAGE_TYPE === "orchestrator" ? getBrowserState().sessionId : getBrowserState().testerId;
|
|
260
260
|
const METHOD = getBrowserState().method;
|
|
261
|
-
const ENTRY_URL = `${location.protocol === "https:" ? "wss:" : "ws:"}//${HOST}/__vitest_browser_api__?type=${PAGE_TYPE}&rpcId=${RPC_ID}&sessionId=${getBrowserState().sessionId}&projectName=${getBrowserState().config.name || ""}&method=${METHOD}`;
|
|
261
|
+
const ENTRY_URL = `${location.protocol === "https:" ? "wss:" : "ws:"}//${HOST}/__vitest_browser_api__?type=${PAGE_TYPE}&rpcId=${RPC_ID}&sessionId=${getBrowserState().sessionId}&projectName=${getBrowserState().config.name || ""}&method=${METHOD}&token=${window.VITEST_API_TOKEN}`;
|
|
262
262
|
let setCancel = (_) => {
|
|
263
263
|
};
|
|
264
264
|
const onCancel = new Promise((resolve) => {
|
package/dist/context.js
CHANGED
|
@@ -114,7 +114,7 @@ function getParent(el) {
|
|
|
114
114
|
const state = () => getWorkerState();
|
|
115
115
|
const provider = __vitest_browser_runner__.provider;
|
|
116
116
|
function filepath() {
|
|
117
|
-
return getWorkerState().filepath || getWorkerState().current?.file?.filepath ||
|
|
117
|
+
return getWorkerState().filepath || getWorkerState().current?.file?.filepath || void 0;
|
|
118
118
|
}
|
|
119
119
|
const rpc = () => getWorkerState().rpc;
|
|
120
120
|
const sessionId = getBrowserState().sessionId;
|
|
@@ -342,7 +342,7 @@ const page = {
|
|
|
342
342
|
const name = options.path || `${taskName.replace(/[^a-z0-9]/gi, "-")}-${number}.png`;
|
|
343
343
|
return ensureAwaited(() => triggerCommand("__vitest_screenshot", name, {
|
|
344
344
|
...options,
|
|
345
|
-
element: options.element ? convertToSelector(options.element) :
|
|
345
|
+
element: options.element ? convertToSelector(options.element) : void 0
|
|
346
346
|
}));
|
|
347
347
|
},
|
|
348
348
|
getByRole() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { server, page } from '@vitest/browser/context';
|
|
2
|
-
import { I as Ivya,
|
|
2
|
+
import { I as Ivya, e as getByRoleSelector, c as getByAltTextSelector, f as getByLabelSelector, b as getByPlaceholderSelector, d as getByTestIdSelector, a as getByTextSelector, g as getByTitleSelector, h as getElementError } from './public-utils-J4vwTaki.js';
|
|
3
3
|
|
|
4
4
|
function ensureAwaited(promise) {
|
|
5
5
|
const test = (/* @__PURE__ */ getWorkerState()).current;
|
|
@@ -260,7 +260,7 @@ class Locator {
|
|
|
260
260
|
return this.worker.rpc;
|
|
261
261
|
}
|
|
262
262
|
triggerCommand(command, ...args) {
|
|
263
|
-
const filepath = this.worker.filepath || this.worker.current?.file?.filepath ||
|
|
263
|
+
const filepath = this.worker.filepath || this.worker.current?.file?.filepath || void 0;
|
|
264
264
|
return ensureAwaited(() => this.rpc.triggerCommand(
|
|
265
265
|
this.state.sessionId,
|
|
266
266
|
command,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'vitest/config';
|
|
2
2
|
import { CDPSession, BrowserServerState as BrowserServerState$1, ProjectBrowser as ProjectBrowser$1, TestProject, BrowserProvider, Vitest, ResolvedConfig, Vite, BrowserCommand, BrowserScript, ProcessPool } from 'vitest/node';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import * as vitest from 'vitest';
|
|
6
|
-
import { RunnerTestFile, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff, ParsedStack } from 'vitest';
|
|
3
|
+
import { ViteDevServer, HtmlTagDescriptor } from 'vite';
|
|
4
|
+
import { CancelReason, RunnerTestFile, AfterSuiteRunMeta, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff, ParsedStack } from 'vitest';
|
|
7
5
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
8
6
|
import { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node';
|
|
9
7
|
import { TaskResultPack, TaskEventPack } from '@vitest/runner';
|
|
@@ -100,11 +98,11 @@ declare class ProjectBrowser implements ProjectBrowser$1 {
|
|
|
100
98
|
parent: ParentBrowserProject;
|
|
101
99
|
state: BrowserServerState;
|
|
102
100
|
constructor(project: TestProject, base: string);
|
|
103
|
-
get vite():
|
|
101
|
+
get vite(): ViteDevServer;
|
|
104
102
|
wrapSerializedConfig(): SerializedConfig;
|
|
105
103
|
initBrowserProvider(project: TestProject): Promise<void>;
|
|
106
|
-
parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions):
|
|
107
|
-
parseStacktrace(trace: string, options?: StackTraceParserOptions):
|
|
104
|
+
parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): ParsedStack[];
|
|
105
|
+
parseStacktrace(trace: string, options?: StackTraceParserOptions): ParsedStack[];
|
|
108
106
|
close(): Promise<void>;
|
|
109
107
|
}
|
|
110
108
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import c from 'tinyrainbow';
|
|
2
|
-
import { getFilePoolName, distDir, resolveApiServerConfig, resolveFsAllow, isFileServingAllowed, createDebugger, createViteLogger, createViteServer } from 'vitest/node';
|
|
2
|
+
import { getFilePoolName, distDir, resolveApiServerConfig, resolveFsAllow, isFileServingAllowed, createDebugger, isValidApiRequest, createViteLogger, createViteServer } from 'vitest/node';
|
|
3
3
|
import fs, { readFileSync, lstatSync, promises, existsSync } from 'node:fs';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { dynamicImportPlugin, ServerMockResolver } from '@vitest/mocker/node';
|
|
@@ -16,7 +16,7 @@ import { resolve as resolve$1, dirname as dirname$1, basename as basename$1, nor
|
|
|
16
16
|
import { WebSocketServer } from 'ws';
|
|
17
17
|
import * as nodeos from 'node:os';
|
|
18
18
|
|
|
19
|
-
var version = "3.0.
|
|
19
|
+
var version = "3.0.6";
|
|
20
20
|
|
|
21
21
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
22
22
|
function normalizeWindowsPath(input = "") {
|
|
@@ -267,7 +267,8 @@ async function resolveOrchestrator(globalServer, url, res) {
|
|
|
267
267
|
__VITEST_TYPE__: '"orchestrator"',
|
|
268
268
|
__VITEST_SESSION_ID__: JSON.stringify(sessionId),
|
|
269
269
|
__VITEST_TESTER_ID__: '"none"',
|
|
270
|
-
__VITEST_PROVIDED_CONTEXT__: "{}"
|
|
270
|
+
__VITEST_PROVIDED_CONTEXT__: "{}",
|
|
271
|
+
__VITEST_API_TOKEN__: JSON.stringify(globalServer.vitest.config.api.token)
|
|
271
272
|
});
|
|
272
273
|
res.removeHeader("Content-Security-Policy");
|
|
273
274
|
if (!globalServer.orchestratorScripts) {
|
|
@@ -416,7 +417,7 @@ const parse = (text, reviver) => {
|
|
|
416
417
|
*/
|
|
417
418
|
const stringify = (value, replacer, space) => {
|
|
418
419
|
const $ = replacer && typeof replacer === object ?
|
|
419
|
-
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v :
|
|
420
|
+
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
|
|
420
421
|
(replacer || noop);
|
|
421
422
|
const known = new Map;
|
|
422
423
|
const input = [];
|
|
@@ -483,7 +484,8 @@ async function resolveTester(globalServer, url, res, next) {
|
|
|
483
484
|
__VITEST_METHOD__: JSON.stringify(method),
|
|
484
485
|
__VITEST_SESSION_ID__: JSON.stringify(sessionId),
|
|
485
486
|
__VITEST_TESTER_ID__: JSON.stringify(crypto.randomUUID()),
|
|
486
|
-
__VITEST_PROVIDED_CONTEXT__: JSON.stringify(stringify(project.getProvidedContext()))
|
|
487
|
+
__VITEST_PROVIDED_CONTEXT__: JSON.stringify(stringify(project.getProvidedContext())),
|
|
488
|
+
__VITEST_API_TOKEN__: JSON.stringify(globalServer.vitest.config.api.token)
|
|
487
489
|
});
|
|
488
490
|
const testerHtml = typeof browserProject.testerHtml === "string" ? browserProject.testerHtml : await browserProject.testerHtml;
|
|
489
491
|
try {
|
|
@@ -625,7 +627,7 @@ var BrowserPlugin = (parentServer, base = "/") => {
|
|
|
625
627
|
}
|
|
626
628
|
);
|
|
627
629
|
const coverageFolder = resolveCoverageFolder(parentServer.vitest);
|
|
628
|
-
const coveragePath = coverageFolder ? coverageFolder[1] :
|
|
630
|
+
const coveragePath = coverageFolder ? coverageFolder[1] : void 0;
|
|
629
631
|
if (coveragePath && base === coveragePath) {
|
|
630
632
|
throw new Error(
|
|
631
633
|
`The ui base path and the coverage path cannot be the same: ${base}, change coverage.reportsDirectory`
|
|
@@ -1067,7 +1069,7 @@ function tryResolve(path, paths) {
|
|
|
1067
1069
|
const _require2 = getRequire();
|
|
1068
1070
|
return _require2.resolve(path, { paths });
|
|
1069
1071
|
} catch {
|
|
1070
|
-
return
|
|
1072
|
+
return void 0;
|
|
1071
1073
|
}
|
|
1072
1074
|
}
|
|
1073
1075
|
let _require;
|
|
@@ -1084,15 +1086,15 @@ function resolveCoverageFolder(vitest) {
|
|
|
1084
1086
|
return reporter === "html";
|
|
1085
1087
|
}
|
|
1086
1088
|
return reporter[0] === "html";
|
|
1087
|
-
}) :
|
|
1089
|
+
}) : void 0;
|
|
1088
1090
|
if (!htmlReporter) {
|
|
1089
|
-
return
|
|
1091
|
+
return void 0;
|
|
1090
1092
|
}
|
|
1091
1093
|
const root = resolve(
|
|
1092
1094
|
options.root || process.cwd(),
|
|
1093
1095
|
options.coverage.reportsDirectory || coverageConfigDefaults.reportsDirectory
|
|
1094
1096
|
);
|
|
1095
|
-
const subdir = Array.isArray(htmlReporter) && htmlReporter.length > 1 && "subdir" in htmlReporter[1] ? htmlReporter[1].subdir :
|
|
1097
|
+
const subdir = Array.isArray(htmlReporter) && htmlReporter.length > 1 && "subdir" in htmlReporter[1] ? htmlReporter[1].subdir : void 0;
|
|
1096
1098
|
if (!subdir || typeof subdir !== "string") {
|
|
1097
1099
|
return [root, `/${basename(root)}/`];
|
|
1098
1100
|
}
|
|
@@ -2462,7 +2464,7 @@ function wrapConfig(config) {
|
|
|
2462
2464
|
return {
|
|
2463
2465
|
...config,
|
|
2464
2466
|
// workaround RegExp serialization
|
|
2465
|
-
testNamePattern: config.testNamePattern ? config.testNamePattern.toString() :
|
|
2467
|
+
testNamePattern: config.testNamePattern ? config.testNamePattern.toString() : void 0
|
|
2466
2468
|
};
|
|
2467
2469
|
}
|
|
2468
2470
|
|
|
@@ -2615,7 +2617,7 @@ class ParentBrowserProject {
|
|
|
2615
2617
|
const server = this.vite;
|
|
2616
2618
|
const promises = scripts.map(
|
|
2617
2619
|
async ({ content, src, async, id, type = "module" }, index) => {
|
|
2618
|
-
const srcLink = (src ? (await server.pluginContainer.resolveId(src))?.id :
|
|
2620
|
+
const srcLink = (src ? (await server.pluginContainer.resolveId(src))?.id : void 0) || src;
|
|
2619
2621
|
const transformId = srcLink || join(server.config.root, `virtual__${id || `injected-${index}.js`}`);
|
|
2620
2622
|
await server.moduleGraph.ensureEntryFromUrl(transformId);
|
|
2621
2623
|
const contentProcessed = content && type === "module" ? (await server.pluginContainer.transform(content, transformId)).code : content;
|
|
@@ -2672,7 +2674,7 @@ function createBirpc(functions, options) {
|
|
|
2672
2674
|
if (method === "$close")
|
|
2673
2675
|
return close;
|
|
2674
2676
|
if (method === "then" && !eventNames.includes("then") && !("then" in functions))
|
|
2675
|
-
return
|
|
2677
|
+
return void 0;
|
|
2676
2678
|
const sendEvent = (...args) => {
|
|
2677
2679
|
post(serialize({ m: method, a: args, t: "q" }));
|
|
2678
2680
|
};
|
|
@@ -2687,7 +2689,7 @@ function createBirpc(functions, options) {
|
|
|
2687
2689
|
try {
|
|
2688
2690
|
await _promise;
|
|
2689
2691
|
} finally {
|
|
2690
|
-
_promise =
|
|
2692
|
+
_promise = void 0;
|
|
2691
2693
|
}
|
|
2692
2694
|
}
|
|
2693
2695
|
return new Promise((resolve, reject) => {
|
|
@@ -2781,6 +2783,10 @@ function setupBrowserRpc(globalServer) {
|
|
|
2781
2783
|
if (pathname !== BROWSER_API_PATH) {
|
|
2782
2784
|
return;
|
|
2783
2785
|
}
|
|
2786
|
+
if (!isValidApiRequest(vitest.config, request)) {
|
|
2787
|
+
socket.destroy();
|
|
2788
|
+
return;
|
|
2789
|
+
}
|
|
2784
2790
|
const type = searchParams.get("type");
|
|
2785
2791
|
const rpcId = searchParams.get("rpcId");
|
|
2786
2792
|
const sessionId = searchParams.get("sessionId");
|
|
@@ -3125,6 +3131,9 @@ function createBrowserPool(vitest) {
|
|
|
3125
3131
|
if (!config.fileParallelism) {
|
|
3126
3132
|
return 1;
|
|
3127
3133
|
}
|
|
3134
|
+
if (project.config.maxWorkers) {
|
|
3135
|
+
return project.config.maxWorkers;
|
|
3136
|
+
}
|
|
3128
3137
|
return vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
3129
3138
|
}
|
|
3130
3139
|
return {
|
package/dist/locators/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '@vitest/browser/context';
|
|
2
|
-
import '../public-utils-
|
|
3
|
-
export { L as Locator, s as selectorEngine } from '../index
|
|
2
|
+
import '../public-utils-J4vwTaki.js';
|
|
3
|
+
export { L as Locator, s as selectorEngine } from '../index-D-kNWeee.js';
|
|
4
4
|
import 'vitest/utils';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { page, server } from '@vitest/browser/context';
|
|
2
|
-
import { g as
|
|
3
|
-
import { s as selectorEngine, L as Locator } from '../index
|
|
2
|
+
import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector } from '../public-utils-J4vwTaki.js';
|
|
3
|
+
import { s as selectorEngine, L as Locator } from '../index-D-kNWeee.js';
|
|
4
4
|
import 'vitest/utils';
|
|
5
5
|
|
|
6
6
|
page.extend({
|
package/dist/locators/preview.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { page, server, userEvent } from '@vitest/browser/context';
|
|
2
|
-
import { g as
|
|
3
|
-
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index
|
|
2
|
+
import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector, h as getElementError } from '../public-utils-J4vwTaki.js';
|
|
3
|
+
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-D-kNWeee.js';
|
|
4
4
|
import 'vitest/utils';
|
|
5
5
|
|
|
6
6
|
page.extend({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { page, server } from '@vitest/browser/context';
|
|
2
|
-
import { g as
|
|
3
|
-
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index
|
|
2
|
+
import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector, h as getElementError } from '../public-utils-J4vwTaki.js';
|
|
3
|
+
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-D-kNWeee.js';
|
|
4
4
|
import 'vitest/utils';
|
|
5
5
|
|
|
6
6
|
page.extend({
|