@rstest/browser 0.9.4 → 0.9.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/dist/browser-container/container-static/js/{927.514b181bd2.js → 407.89ee95c89d.js} +622 -615
- package/dist/browser-container/container-static/js/407.89ee95c89d.js.LICENSE.txt +1 -0
- package/dist/browser-container/container-static/js/{index.5acf502b10.js → index.3ad6624086.js} +7 -7
- package/dist/browser-container/index.html +1 -1
- package/dist/client/dispatchTransport.d.ts +0 -1
- package/dist/client/sourceMapSupport.d.ts +2 -5
- package/dist/concurrency.d.ts +2 -2
- package/dist/dispatchCapabilities.d.ts +1 -1
- package/dist/headedSerialTaskQueue.d.ts +2 -1
- package/dist/headlessLatestRerunScheduler.d.ts +1 -1
- package/dist/hostController.d.ts +13 -1
- package/dist/index.js +260 -28
- package/dist/protocol.d.ts +1 -5
- package/dist/rpcProtocol.d.ts +0 -13
- package/dist/sessionRegistry.d.ts +1 -1
- package/dist/watchRerunPlanner.d.ts +2 -2
- package/package.json +19 -20
- package/src/client/dispatchTransport.ts +1 -1
- package/src/client/sourceMapSupport.ts +1 -9
- package/src/concurrency.ts +2 -2
- package/src/configValidation.ts +7 -1
- package/src/dispatchCapabilities.ts +1 -1
- package/src/headedSerialTaskQueue.ts +1 -1
- package/src/headlessLatestRerunScheduler.ts +1 -1
- package/src/hostController.ts +49 -11
- package/src/protocol.ts +0 -9
- package/src/rpcProtocol.ts +0 -15
- package/src/sessionRegistry.ts +1 -1
- package/src/watchCliShortcuts.ts +3 -1
- package/src/watchRerunPlanner.ts +2 -2
- package/dist/browser-container/container-static/js/927.514b181bd2.js.LICENSE.txt +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TestFileInfo } from './protocol';
|
|
2
|
-
|
|
2
|
+
type WatchPlannerProjectEntry = {
|
|
3
3
|
project: {
|
|
4
4
|
name: string;
|
|
5
5
|
};
|
|
@@ -10,7 +10,7 @@ type WatchRerunPlannerInput = {
|
|
|
10
10
|
previousTestFiles: TestFileInfo[];
|
|
11
11
|
affectedTestFiles: string[];
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type WatchRerunPlan = {
|
|
14
14
|
currentTestFiles: TestFileInfo[];
|
|
15
15
|
filesChanged: boolean;
|
|
16
16
|
normalizedAffectedTestFiles: string[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/browser",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "Browser mode support for Rstest testing framework.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rstest",
|
|
7
|
+
"browser",
|
|
8
|
+
"test",
|
|
9
|
+
"rstack",
|
|
10
|
+
"rspack"
|
|
11
|
+
],
|
|
5
12
|
"bugs": {
|
|
6
13
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
7
14
|
},
|
|
@@ -10,16 +17,8 @@
|
|
|
10
17
|
"url": "https://github.com/web-infra-dev/rstest",
|
|
11
18
|
"directory": "packages/browser"
|
|
12
19
|
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"rstest",
|
|
15
|
-
"browser",
|
|
16
|
-
"test",
|
|
17
|
-
"rstack",
|
|
18
|
-
"rspack"
|
|
19
|
-
],
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"type": "module",
|
|
22
|
-
"main": "./dist/index.js",
|
|
23
22
|
"exports": {
|
|
24
23
|
".": {
|
|
25
24
|
"types": "./dist/browser.d.ts",
|
|
@@ -33,6 +32,7 @@
|
|
|
33
32
|
"default": "./package.json"
|
|
34
33
|
}
|
|
35
34
|
},
|
|
35
|
+
"main": "./dist/index.js",
|
|
36
36
|
"files": [
|
|
37
37
|
"dist",
|
|
38
38
|
"src",
|
|
@@ -45,26 +45,25 @@
|
|
|
45
45
|
"open-editor": "^6.0.0",
|
|
46
46
|
"pathe": "^2.0.3",
|
|
47
47
|
"sirv": "^3.0.2",
|
|
48
|
-
"ws": "^8.
|
|
48
|
+
"ws": "^8.20.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@rslib/core": "0.20.
|
|
51
|
+
"@rslib/core": "0.20.2",
|
|
52
52
|
"@types/convert-source-map": "^2.0.3",
|
|
53
53
|
"@types/picomatch": "^4.0.2",
|
|
54
54
|
"@types/ws": "^8.18.1",
|
|
55
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
55
|
+
"@typescript/native-preview": "7.0.0-dev.20260331.1",
|
|
56
56
|
"@vitest/snapshot": "^3.2.4",
|
|
57
57
|
"birpc": "^4.0.0",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
58
|
+
"picomatch": "^4.0.4",
|
|
59
|
+
"playwright": "^1.59.0",
|
|
60
|
+
"@rstest/browser-ui": "0.0.0",
|
|
61
61
|
"@rstest/tsconfig": "0.0.1",
|
|
62
|
-
"@rstest/core": "0.9.
|
|
63
|
-
"@rstest/browser-ui": "0.0.0"
|
|
62
|
+
"@rstest/core": "0.9.6"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
65
|
"playwright": "^1.49.1",
|
|
67
|
-
"@rstest/core": "^0.9.
|
|
66
|
+
"@rstest/core": "^0.9.6"
|
|
68
67
|
},
|
|
69
68
|
"peerDependenciesMeta": {
|
|
70
69
|
"playwright": {
|
|
@@ -80,7 +79,7 @@
|
|
|
80
79
|
},
|
|
81
80
|
"scripts": {
|
|
82
81
|
"build": "rslib build",
|
|
83
|
-
"
|
|
84
|
-
"
|
|
82
|
+
"dev": "rslib build --watch",
|
|
83
|
+
"typecheck": "pnpm -w exec tsc --noEmit -p packages/browser/tsconfig.json"
|
|
85
84
|
}
|
|
86
85
|
}
|
|
@@ -111,18 +111,10 @@ export const preloadRunnerSourceMap = async (): Promise<void> => {
|
|
|
111
111
|
await preloadSourceMap(runnerUrl);
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
* Clear cache (for testing purposes)
|
|
116
|
-
*/
|
|
117
|
-
export const clearCache = (): void => {
|
|
118
|
-
sourceMapCache.clear();
|
|
119
|
-
sourceMapPayloadCache.clear();
|
|
120
|
-
};
|
|
121
|
-
|
|
122
114
|
/**
|
|
123
115
|
* Stack frame interface matching @vitest/snapshot's format
|
|
124
116
|
*/
|
|
125
|
-
|
|
117
|
+
interface StackFrame {
|
|
126
118
|
file: string;
|
|
127
119
|
line: number;
|
|
128
120
|
column: number;
|
package/src/concurrency.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Rstest } from '@rstest/core/browser';
|
|
|
5
5
|
// Keep this in one place so executors reuse the same worker semantics.
|
|
6
6
|
const DEFAULT_MAX_HEADLESS_WORKERS = 12;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type HeadlessConcurrencyContext = Pick<Rstest, 'command'> & {
|
|
9
9
|
normalizedConfig: {
|
|
10
10
|
pool: {
|
|
11
11
|
maxWorkers?: string | number;
|
|
@@ -13,7 +13,7 @@ export type HeadlessConcurrencyContext = Pick<Rstest, 'command'> & {
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const getNumCpus = (): number => {
|
|
17
17
|
return os.availableParallelism?.() ?? os.cpus().length;
|
|
18
18
|
};
|
|
19
19
|
|
package/src/configValidation.ts
CHANGED
|
@@ -44,7 +44,7 @@ const validateViewport = (viewport: unknown): void => {
|
|
|
44
44
|
|
|
45
45
|
export const validateBrowserConfig = (context: Rstest): void => {
|
|
46
46
|
for (const project of context.projects) {
|
|
47
|
-
const browser = project.normalizedConfig
|
|
47
|
+
const { browser, output } = project.normalizedConfig;
|
|
48
48
|
if (!browser.enabled) {
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
@@ -66,5 +66,11 @@ export const validateBrowserConfig = (context: Rstest): void => {
|
|
|
66
66
|
if (!isPlainObject(browser.providerOptions)) {
|
|
67
67
|
throw new Error('browser.providerOptions must be a plain object.');
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
if (output?.bundleDependencies === false) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
'output.bundleDependencies false is not supported in browser mode.',
|
|
73
|
+
);
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
};
|
|
@@ -27,7 +27,7 @@ type RunnerDispatchSuiteStartPayload = ReporterHookArg<'onTestSuiteStart'>;
|
|
|
27
27
|
type RunnerDispatchSuiteResultPayload = ReporterHookArg<'onTestSuiteResult'>;
|
|
28
28
|
type RunnerDispatchCaseStartPayload = ReporterHookArg<'onTestCaseStart'>;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
type RunnerDispatchCallbacks = {
|
|
31
31
|
onTestFileStart: (payload: RunnerPayload<'file-start'>) => Promise<void>;
|
|
32
32
|
onTestFileReady: (payload: RunnerDispatchFileReadyPayload) => Promise<void>;
|
|
33
33
|
onTestSuiteStart: (payload: RunnerDispatchSuiteStartPayload) => Promise<void>;
|
package/src/hostController.ts
CHANGED
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
type RuntimeConfig,
|
|
23
23
|
rsbuild,
|
|
24
24
|
serializableConfig,
|
|
25
|
-
TEMP_RSTEST_OUTPUT_DIR,
|
|
26
25
|
type Test,
|
|
27
26
|
type TestFileResult,
|
|
28
27
|
type TestResult,
|
|
@@ -519,6 +518,30 @@ type BrowserLazyCompilationConfig = {
|
|
|
519
518
|
test?: (module: LazyCompilationModule) => boolean;
|
|
520
519
|
};
|
|
521
520
|
|
|
521
|
+
/**
|
|
522
|
+
* Resolve the actual port the dev server is listening on.
|
|
523
|
+
*
|
|
524
|
+
* Rsbuild's `devServer.listen()` may return `0` when configured with
|
|
525
|
+
* `server.port: 0` because its internal `getPort` never reads back the
|
|
526
|
+
* OS-assigned ephemeral port. This helper falls back to
|
|
527
|
+
* `httpServer.address()` to obtain the real bound port.
|
|
528
|
+
*/
|
|
529
|
+
export const resolveListenPort = (
|
|
530
|
+
listenPort: number,
|
|
531
|
+
httpServer: {
|
|
532
|
+
address: () => ReturnType<import('node:net').Server['address']>;
|
|
533
|
+
} | null,
|
|
534
|
+
): number => {
|
|
535
|
+
if (listenPort) {
|
|
536
|
+
return listenPort;
|
|
537
|
+
}
|
|
538
|
+
const addr = httpServer?.address();
|
|
539
|
+
if (addr && typeof addr === 'object') {
|
|
540
|
+
return addr.port;
|
|
541
|
+
}
|
|
542
|
+
return listenPort;
|
|
543
|
+
};
|
|
544
|
+
|
|
522
545
|
export const createBrowserLazyCompilationConfig = (
|
|
523
546
|
setupFiles: string[],
|
|
524
547
|
): BrowserLazyCompilationConfig => {
|
|
@@ -543,11 +566,12 @@ export const createBrowserLazyCompilationConfig = (
|
|
|
543
566
|
};
|
|
544
567
|
};
|
|
545
568
|
|
|
546
|
-
export const createBrowserRsbuildDevConfig = (
|
|
569
|
+
export const createBrowserRsbuildDevConfig = (_isWatchMode: boolean) => {
|
|
547
570
|
return {
|
|
548
|
-
|
|
549
|
-
//
|
|
550
|
-
|
|
571
|
+
writeToDisk: isDebug(),
|
|
572
|
+
// Keep HMR enabled in browser mode even for one-shot runs.
|
|
573
|
+
// lazyCompilation depends on HMR runtime wiring for async import chains.
|
|
574
|
+
hmr: true,
|
|
551
575
|
client: {
|
|
552
576
|
logLevel: 'error' as const,
|
|
553
577
|
},
|
|
@@ -1389,6 +1413,18 @@ const createBrowserRuntime = async ({
|
|
|
1389
1413
|
getPortSilently: true,
|
|
1390
1414
|
});
|
|
1391
1415
|
|
|
1416
|
+
if (isDebug()) {
|
|
1417
|
+
await rsbuildInstance.inspectConfig({
|
|
1418
|
+
writeToDisk: true,
|
|
1419
|
+
extraConfigs: {
|
|
1420
|
+
rstest: {
|
|
1421
|
+
...context.normalizedConfig,
|
|
1422
|
+
projects: browserProjects.map((p) => p.normalizedConfig),
|
|
1423
|
+
},
|
|
1424
|
+
},
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1392
1428
|
// Serve prebuilt container assets (SPA) via sirv
|
|
1393
1429
|
const serveContainer = containerDistPath
|
|
1394
1430
|
? sirv(containerDistPath, {
|
|
@@ -1537,7 +1573,8 @@ const createBrowserRuntime = async ({
|
|
|
1537
1573
|
},
|
|
1538
1574
|
);
|
|
1539
1575
|
|
|
1540
|
-
const { port } = await devServer.listen();
|
|
1576
|
+
const { port: listenPort } = await devServer.listen();
|
|
1577
|
+
const port = resolveListenPort(listenPort, devServer.httpServer);
|
|
1541
1578
|
|
|
1542
1579
|
// Create WebSocket server on an available port
|
|
1543
1580
|
// Using port: 0 lets the OS assign an available port, avoiding conflicts
|
|
@@ -1574,10 +1611,10 @@ const createBrowserRuntime = async ({
|
|
|
1574
1611
|
dispatchHandlers,
|
|
1575
1612
|
wss,
|
|
1576
1613
|
};
|
|
1577
|
-
} catch (
|
|
1614
|
+
} catch (error) {
|
|
1578
1615
|
wss.close();
|
|
1579
1616
|
await devServer.close();
|
|
1580
|
-
throw
|
|
1617
|
+
throw error;
|
|
1581
1618
|
}
|
|
1582
1619
|
};
|
|
1583
1620
|
|
|
@@ -1831,14 +1868,15 @@ export const runBrowserController = async (
|
|
|
1831
1868
|
|
|
1832
1869
|
const isWatchMode = context.command === 'watch';
|
|
1833
1870
|
const enableCliShortcuts = isWatchMode && isBrowserWatchCliShortcutsEnabled();
|
|
1871
|
+
const browserTempOutputRoot = context.normalizedConfig.output.distPath.root;
|
|
1834
1872
|
const tempDir =
|
|
1835
1873
|
isWatchMode && watchContext.runtime
|
|
1836
1874
|
? watchContext.runtime.tempDir
|
|
1837
1875
|
: isWatchMode
|
|
1838
|
-
? join(context.rootPath,
|
|
1876
|
+
? join(context.rootPath, browserTempOutputRoot, 'browser', 'watch')
|
|
1839
1877
|
: join(
|
|
1840
1878
|
context.rootPath,
|
|
1841
|
-
|
|
1879
|
+
browserTempOutputRoot,
|
|
1842
1880
|
'browser',
|
|
1843
1881
|
Date.now().toString(),
|
|
1844
1882
|
);
|
|
@@ -3225,7 +3263,7 @@ export const listBrowserTests = async (
|
|
|
3225
3263
|
|
|
3226
3264
|
const tempDir = join(
|
|
3227
3265
|
context.rootPath,
|
|
3228
|
-
|
|
3266
|
+
context.normalizedConfig.output.distPath.root,
|
|
3229
3267
|
'browser',
|
|
3230
3268
|
`list-${Date.now()}`,
|
|
3231
3269
|
);
|
package/src/protocol.ts
CHANGED
|
@@ -9,12 +9,8 @@ import type { SnapshotUpdateState } from '@vitest/snapshot';
|
|
|
9
9
|
|
|
10
10
|
export type {
|
|
11
11
|
BrowserLocatorIR,
|
|
12
|
-
BrowserLocatorStep,
|
|
13
|
-
BrowserLocatorText,
|
|
14
12
|
BrowserRpcRequest,
|
|
15
|
-
BrowserRpcResponse,
|
|
16
13
|
SnapshotRpcRequest,
|
|
17
|
-
SnapshotRpcResponse,
|
|
18
14
|
} from './rpcProtocol';
|
|
19
15
|
export { validateBrowserRpcRequest } from './rpcProtocol';
|
|
20
16
|
|
|
@@ -166,11 +162,6 @@ export type BrowserDispatchResponse = {
|
|
|
166
162
|
stale?: boolean;
|
|
167
163
|
};
|
|
168
164
|
|
|
169
|
-
export type BrowserDispatchResponseEnvelope = {
|
|
170
|
-
type: typeof DISPATCH_RESPONSE_TYPE;
|
|
171
|
-
payload: BrowserDispatchResponse;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
165
|
export type BrowserDispatchHandler = (
|
|
175
166
|
request: BrowserDispatchRequest,
|
|
176
167
|
) => Promise<unknown>;
|
package/src/rpcProtocol.ts
CHANGED
|
@@ -178,12 +178,6 @@ export const validateBrowserRpcRequest = (
|
|
|
178
178
|
return request;
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
-
export type BrowserRpcResponse = {
|
|
182
|
-
id: string;
|
|
183
|
-
result?: unknown;
|
|
184
|
-
error?: string;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
181
|
/**
|
|
188
182
|
* Snapshot RPC request from runner iframe.
|
|
189
183
|
* The container will forward these to the host via WebSocket RPC.
|
|
@@ -209,12 +203,3 @@ export type SnapshotRpcRequest =
|
|
|
209
203
|
method: 'removeSnapshotFile';
|
|
210
204
|
args: { filepath: string };
|
|
211
205
|
};
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Snapshot RPC response from container to runner iframe.
|
|
215
|
-
*/
|
|
216
|
-
export type SnapshotRpcResponse = {
|
|
217
|
-
id: string;
|
|
218
|
-
result?: unknown;
|
|
219
|
-
error?: string;
|
|
220
|
-
};
|
package/src/sessionRegistry.ts
CHANGED
package/src/watchCliShortcuts.ts
CHANGED
package/src/watchRerunPlanner.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalize } from 'pathe';
|
|
2
2
|
import type { TestFileInfo } from './protocol';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type WatchPlannerProjectEntry = {
|
|
5
5
|
project: {
|
|
6
6
|
name: string;
|
|
7
7
|
};
|
|
@@ -14,7 +14,7 @@ type WatchRerunPlannerInput = {
|
|
|
14
14
|
affectedTestFiles: string[];
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
type WatchRerunPlan = {
|
|
18
18
|
currentTestFiles: TestFileInfo[];
|
|
19
19
|
filesChanged: boolean;
|
|
20
20
|
normalizedAffectedTestFiles: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! LICENSE: 927.514b181bd2.js.LICENSE.txt */
|