@rstest/browser 0.11.6 → 0.11.7
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/css/index.43daaf6c93.css +1 -0
- package/dist/browser-container/container-static/js/260.3739fe815c.js +194 -0
- package/dist/browser-container/container-static/js/index.c0f87bfb3e.js +1 -0
- package/dist/browser-container/index.html +1 -1
- package/dist/browserRsbuild.d.ts +24 -4
- package/dist/browserV8Coverage.d.ts +15 -0
- package/dist/client/240~1.js +150 -0
- package/dist/{augmentExpect.d.ts → client/client/augmentExpect.d.ts} +1 -1
- package/dist/client/{browserRpc.d.ts → client/browserRpc.d.ts} +1 -1
- package/dist/client/{dispatchTransport.d.ts → client/dispatchTransport.d.ts} +8 -4
- package/dist/client/client/index.d.ts +2 -0
- package/dist/client/client/runIdentity.d.ts +12 -0
- package/dist/client/client/runner.d.ts +4 -0
- package/dist/client/client/snapshot.d.ts +27 -0
- package/dist/client/client/sourceMapSupport.d.ts +36 -0
- package/dist/{browser.js → client/index.js} +3 -102
- package/dist/client/protocol.d.ts +225 -0
- package/dist/client/rpcProtocol.d.ts +138 -0
- package/dist/client/runner.js +675 -0
- package/dist/client/sourceMap/sourceMapLoader.d.ts +25 -0
- package/dist/containerRpc.d.ts +27 -19
- package/dist/headedRunRegistry.d.ts +51 -0
- package/dist/headedScheduler.d.ts +10 -10
- package/dist/headlessScheduler.d.ts +5 -4
- package/dist/headlessTransport.d.ts +4 -2
- package/dist/hostPayloads.d.ts +1 -7
- package/dist/index.js +840 -330
- package/dist/protocol.d.ts +48 -8
- package/dist/providers/index.d.ts +21 -0
- package/dist/providers/playwright/v8Coverage.d.ts +2 -0
- package/dist/rpcProtocol.d.ts +1 -2
- package/dist/schedulerSeam.d.ts +5 -0
- package/dist/sourceMap/sourceMapLoader.d.ts +12 -1
- package/dist/watchRerunPlanner.d.ts +20 -9
- package/dist/watchSignals.d.ts +8 -1
- package/package.json +10 -10
- package/dist/33.js +0 -7
- package/dist/browser-container/container-static/css/index.0521ff95b1.css +0 -1
- package/dist/browser-container/container-static/js/683.4f821ce8f1.js +0 -194
- package/dist/browser-container/container-static/js/index.568aa7cb35.js +0 -1
- package/dist/browser.d.ts +0 -2
- package/src/augmentExpect.ts +0 -62
- package/src/browser.ts +0 -3
- package/src/browserExecutor.ts +0 -222
- package/src/browserRpcRegistry.ts +0 -57
- package/src/browserRsbuild.ts +0 -1927
- package/src/client/api.ts +0 -213
- package/src/client/browserRpc.ts +0 -86
- package/src/client/dispatchTransport.ts +0 -240
- package/src/client/entry.ts +0 -807
- package/src/client/locator.ts +0 -448
- package/src/client/snapshot.ts +0 -113
- package/src/client/sourceMapSupport.ts +0 -159
- package/src/concurrency.ts +0 -65
- package/src/configValidation.ts +0 -263
- package/src/containerRpc.ts +0 -206
- package/src/dispatchCapabilities.ts +0 -177
- package/src/dispatchRouter.ts +0 -82
- package/src/env.d.ts +0 -54
- package/src/headedScheduler.ts +0 -664
- package/src/headedSerialTaskQueue.ts +0 -23
- package/src/headlessScheduler.ts +0 -566
- package/src/headlessTransport.ts +0 -28
- package/src/hostController.ts +0 -1365
- package/src/hostPayloads.ts +0 -62
- package/src/index.ts +0 -51
- package/src/manifest.d.ts +0 -41
- package/src/protocol.ts +0 -225
- package/src/providers/index.ts +0 -126
- package/src/providers/playwright/compileLocator.ts +0 -130
- package/src/providers/playwright/dispatchBrowserRpc.ts +0 -372
- package/src/providers/playwright/expectUtils.ts +0 -57
- package/src/providers/playwright/implementation.ts +0 -35
- package/src/providers/playwright/index.ts +0 -1
- package/src/providers/playwright/runtime.ts +0 -159
- package/src/providers/playwright/textMatcher.ts +0 -10
- package/src/rpcProtocol.ts +0 -218
- package/src/runSession.ts +0 -110
- package/src/schedulerSeam.ts +0 -49
- package/src/sessionRegistry.ts +0 -89
- package/src/sourceMap/sourceMapLoader.ts +0 -96
- package/src/viewportPresets.ts +0 -69
- package/src/watchRerunPlanner.ts +0 -88
- package/src/watchRuntime.ts +0 -83
- package/src/watchSignals.ts +0 -93
- /package/dist/{rslib-runtime.js → 612~0.js} +0 -0
- /package/dist/client/{api.d.ts → client/api.d.ts} +0 -0
- /package/dist/client/{locator.d.ts → client/locator.d.ts} +0 -0
package/src/watchRerunPlanner.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { normalize } from 'pathe';
|
|
2
|
-
import type { TestFileInfo } from './protocol';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Paths the previous cycle ran that the current file set no longer contains.
|
|
6
|
-
* Core prunes its own state from this, so a file deleted mid-session stops
|
|
7
|
-
* being reported instead of lingering as a passing result.
|
|
8
|
-
*/
|
|
9
|
-
export const collectDeletedTestPaths = (
|
|
10
|
-
previous: TestFileInfo[],
|
|
11
|
-
current: TestFileInfo[],
|
|
12
|
-
): string[] => {
|
|
13
|
-
const currentPathSet = new Set(current.map((file) => file.testPath));
|
|
14
|
-
return previous
|
|
15
|
-
.map((file) => file.testPath)
|
|
16
|
-
.filter((testPath) => !currentPathSet.has(testPath));
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type WatchPlannerProjectEntry = {
|
|
20
|
-
project: {
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
testFiles: string[];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type WatchRerunPlannerInput = {
|
|
27
|
-
projectEntries: WatchPlannerProjectEntry[];
|
|
28
|
-
previousTestFiles: TestFileInfo[];
|
|
29
|
-
affectedTestFiles: string[];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type WatchRerunPlan = {
|
|
33
|
-
currentTestFiles: TestFileInfo[];
|
|
34
|
-
filesChanged: boolean;
|
|
35
|
-
normalizedAffectedTestFiles: string[];
|
|
36
|
-
affectedTestFiles: TestFileInfo[];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const serializeTestFiles = (files: TestFileInfo[]): string => {
|
|
40
|
-
return JSON.stringify(
|
|
41
|
-
files.map((f) => `${f.projectName}:${f.testPath}`).sort(),
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const normalizeTestFiles = (files: TestFileInfo[]): TestFileInfo[] => {
|
|
46
|
-
return files.map((file) => ({
|
|
47
|
-
...file,
|
|
48
|
-
testPath: normalize(file.testPath),
|
|
49
|
-
}));
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const collectWatchTestFiles = (
|
|
53
|
-
projectEntries: WatchPlannerProjectEntry[],
|
|
54
|
-
): TestFileInfo[] => {
|
|
55
|
-
return projectEntries.flatMap((entry) =>
|
|
56
|
-
entry.testFiles.map((testPath) => ({
|
|
57
|
-
testPath: normalize(testPath),
|
|
58
|
-
projectName: entry.project.name,
|
|
59
|
-
})),
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const planWatchRerun = ({
|
|
64
|
-
projectEntries,
|
|
65
|
-
previousTestFiles,
|
|
66
|
-
affectedTestFiles,
|
|
67
|
-
}: WatchRerunPlannerInput): WatchRerunPlan => {
|
|
68
|
-
const currentTestFiles = collectWatchTestFiles(projectEntries);
|
|
69
|
-
const normalizedPrevious = normalizeTestFiles(previousTestFiles);
|
|
70
|
-
const filesChanged =
|
|
71
|
-
serializeTestFiles(currentTestFiles) !==
|
|
72
|
-
serializeTestFiles(normalizedPrevious);
|
|
73
|
-
|
|
74
|
-
const normalizedAffectedTestFiles = affectedTestFiles.map((testFile) =>
|
|
75
|
-
normalize(testFile),
|
|
76
|
-
);
|
|
77
|
-
const affectedPathSet = new Set(normalizedAffectedTestFiles);
|
|
78
|
-
const matchedAffectedFiles = currentTestFiles.filter((file) =>
|
|
79
|
-
affectedPathSet.has(file.testPath),
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
currentTestFiles,
|
|
84
|
-
filesChanged,
|
|
85
|
-
normalizedAffectedTestFiles,
|
|
86
|
-
affectedTestFiles: matchedAffectedFiles,
|
|
87
|
-
};
|
|
88
|
-
};
|
package/src/watchRuntime.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { FATAL_SIGNALS } from '@rstest/core/internal/browser';
|
|
2
|
-
import { destroyBrowserRuntime, type BrowserRuntime } from './browserRsbuild';
|
|
3
|
-
|
|
4
|
-
// Only process-wide concerns stay module-level: the runtime handle reused
|
|
5
|
-
// across controller re-entry (config-change restarts), and the signal/exit
|
|
6
|
-
// cleanup that must run once per process. Diff/rerun state lives on
|
|
7
|
-
// `BrowserRuntime.watchState`.
|
|
8
|
-
export type WatchContext = {
|
|
9
|
-
runtime: BrowserRuntime | null;
|
|
10
|
-
cleanupRegistered: boolean;
|
|
11
|
-
cleanupPromise: Promise<void> | null;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const watchContext: WatchContext = {
|
|
15
|
-
runtime: null,
|
|
16
|
-
cleanupRegistered: false,
|
|
17
|
-
cleanupPromise: null,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Tear down the persistent watch runtime (dev servers, provider, browser,
|
|
22
|
-
* WebSocket server). Idempotent, and the single teardown the browser executor's
|
|
23
|
-
* `close` and the process-exit nets both go through.
|
|
24
|
-
*/
|
|
25
|
-
export const runWatchRuntimeTeardown = <T>(
|
|
26
|
-
state: { runtime: T | null; cleanupPromise: Promise<void> | null },
|
|
27
|
-
destroy: (runtime: T) => Promise<void>,
|
|
28
|
-
): Promise<void> => {
|
|
29
|
-
if (state.cleanupPromise) {
|
|
30
|
-
return state.cleanupPromise;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
state.cleanupPromise = (async () => {
|
|
34
|
-
if (!state.runtime) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await destroy(state.runtime);
|
|
39
|
-
state.runtime = null;
|
|
40
|
-
})();
|
|
41
|
-
|
|
42
|
-
// The memo is released once this teardown settles, because the state outlives
|
|
43
|
-
// the session: a config-file change restarts the run against a fresh runtime,
|
|
44
|
-
// and a memo left resolved from the previous session would make every later
|
|
45
|
-
// teardown a no-op — leaving the session after that to reuse a runtime built
|
|
46
|
-
// from the pre-restart config. Idempotency only has to hold within a runtime.
|
|
47
|
-
return state.cleanupPromise.finally(() => {
|
|
48
|
-
state.cleanupPromise = null;
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const cleanupWatchRuntime = (): Promise<void> =>
|
|
53
|
-
// `cleanupRegistered` is deliberately not re-armed alongside the memo: the
|
|
54
|
-
// signal nets it installs read `watchContext.runtime` live, so they stay
|
|
55
|
-
// correct across a restart, and re-registering would stack a fresh set of
|
|
56
|
-
// listeners on every one.
|
|
57
|
-
runWatchRuntimeTeardown(watchContext, destroyBrowserRuntime);
|
|
58
|
-
|
|
59
|
-
export const registerWatchCleanup = (embedded: boolean): void => {
|
|
60
|
-
if (watchContext.cleanupRegistered) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
watchContext.cleanupRegistered = true;
|
|
64
|
-
|
|
65
|
-
// Embedded (programmatic) hosts own the process lifecycle; they tear the
|
|
66
|
-
// session down through the browser executor's `close` instead of signals.
|
|
67
|
-
if (embedded) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Cleanup-only nets: core's watch loop owns the signal → exit-code path and
|
|
72
|
-
// awaits the same idempotent `cleanupWatchRuntime` promise through the
|
|
73
|
-
// browser executor's `close`.
|
|
74
|
-
for (const signal of FATAL_SIGNALS) {
|
|
75
|
-
process.once(signal, () => {
|
|
76
|
-
void cleanupWatchRuntime();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
process.once('exit', () => {
|
|
81
|
-
void cleanupWatchRuntime();
|
|
82
|
-
});
|
|
83
|
-
};
|
package/src/watchSignals.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
color,
|
|
3
|
-
type ExecutorInvalidationCallback,
|
|
4
|
-
logger,
|
|
5
|
-
} from '@rstest/core/internal/browser';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The handover between this host's rerun triggers and core's watch-cycle
|
|
9
|
-
* driver. Triggers reach it from three unrelated places — the bundler's
|
|
10
|
-
* dev-compile hook, a CLI shortcut's fanout, the in-page rerun button — and
|
|
11
|
-
* only the ordering inside `signalInvalidation` keeps them from racing each
|
|
12
|
-
* other. Each run branch installs the pieces it owns; nothing here knows which
|
|
13
|
-
* branch is running.
|
|
14
|
-
*/
|
|
15
|
-
export type WatchSignals = ReturnType<typeof createWatchSignals>;
|
|
16
|
-
|
|
17
|
-
export const createWatchSignals = (
|
|
18
|
-
onInvalidate: ExecutorInvalidationCallback | undefined,
|
|
19
|
-
) => {
|
|
20
|
-
// The transport-owned rerun trigger, installed by whichever run branch
|
|
21
|
-
// (headless/headed) is driving this run: resolve this rebuild's scope, then
|
|
22
|
-
// hand it to core's invalidation subscriber. Populated after the initial
|
|
23
|
-
// cycle.
|
|
24
|
-
let dispatchRerun: (() => Promise<void>) | undefined;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Latest-wins interrupt, installed by the run branch whose in-flight run can
|
|
28
|
-
* be cut short (headless). Core serializes cycles, so a trigger arriving
|
|
29
|
-
* mid-cycle would otherwise wait out a run the user has already superseded.
|
|
30
|
-
*/
|
|
31
|
-
let interruptInFlightRun: (() => Promise<void>) | undefined;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The cycle core is running for the scope last signalled. Only an explicit
|
|
35
|
-
* request awaits it, right after it dispatched: a CLI shortcut's
|
|
36
|
-
* `updateSnapshot` stays flipped only until `requestRerun` resolves, and the
|
|
37
|
-
* in-page rerun button answers its RPC when the rerun is done. A rejection is
|
|
38
|
-
* reported here rather than left to an awaiting caller, because compile-driven
|
|
39
|
-
* triggers have no caller — and a failed cycle must not end the session.
|
|
40
|
-
*/
|
|
41
|
-
let signalledCycle: Promise<void> | undefined;
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
setDispatchRerun(fn: () => Promise<void>): void {
|
|
45
|
-
dispatchRerun = fn;
|
|
46
|
-
},
|
|
47
|
-
async runDispatchRerun(): Promise<void> {
|
|
48
|
-
await dispatchRerun?.();
|
|
49
|
-
},
|
|
50
|
-
setInterrupt(fn: () => Promise<void>): void {
|
|
51
|
-
interruptInFlightRun = fn;
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Hand the scope this trigger resolved to core, which resets the cycle state,
|
|
55
|
-
* calls back into the session's `runCycle`, and finalizes.
|
|
56
|
-
*
|
|
57
|
-
* The cycle is deliberately *not* awaited here. Rebuild triggers reach this
|
|
58
|
-
* from inside the bundler's dev-compile hook, and the bundler keeps no
|
|
59
|
-
* watcher attached while that hook is pending: anything created or deleted in
|
|
60
|
-
* that window is never seen, so it never rebuilds and never reruns. Holding
|
|
61
|
-
* the hook for a whole cycle widens that blind window to the cycle's full
|
|
62
|
-
* duration, which loses test files added or removed mid-run for good. Core
|
|
63
|
-
* serializes the cycles itself, so nothing here has to.
|
|
64
|
-
*
|
|
65
|
-
* The in-flight run is cut short here rather than at the trigger, because only
|
|
66
|
-
* this point knows a replacement cycle is actually coming: a trigger that
|
|
67
|
-
* resolves to no affected files must leave the running cycle alone, or it
|
|
68
|
-
* finalizes on results it never produced.
|
|
69
|
-
*/
|
|
70
|
-
async signalInvalidation(
|
|
71
|
-
fileFilters: string[],
|
|
72
|
-
/**
|
|
73
|
-
* Run state this trigger binds to its own paths, taken in the same turn as
|
|
74
|
-
* the handover — after any interrupt, so no queued cycle can be dequeued in
|
|
75
|
-
* between and read it. The headed rerun's per-file test-name pattern is the
|
|
76
|
-
* one such state; core's cycle options cannot carry it, so the only thing
|
|
77
|
-
* that makes it the property of one cycle is claiming it here.
|
|
78
|
-
*/
|
|
79
|
-
claimScope?: () => void,
|
|
80
|
-
): Promise<void> {
|
|
81
|
-
await interruptInFlightRun?.();
|
|
82
|
-
claimScope?.();
|
|
83
|
-
signalledCycle = Promise.resolve(
|
|
84
|
-
onInvalidate?.({ isFirstBuild: false, fileFilters }),
|
|
85
|
-
).catch((error) => {
|
|
86
|
-
logger.error(color.red('Browser Mode watch cycle failed:'), error);
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
async awaitSignalledCycle(): Promise<void> {
|
|
90
|
-
await signalledCycle;
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|