@rstest/browser 0.11.2 → 0.11.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/browser",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "Browser mode support for Rstest testing framework.",
5
5
  "keywords": [
6
6
  "rstest",
@@ -45,24 +45,24 @@
45
45
  "open-editor": "^6.0.0",
46
46
  "pathe": "^2.0.3",
47
47
  "sirv": "^3.0.2",
48
- "ws": "^8.21.0"
48
+ "ws": "^8.21.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@rslib/core": "0.23.2",
51
+ "@rslib/core": "1.0.0-beta.1",
52
52
  "@types/convert-source-map": "^2.0.3",
53
53
  "@types/picomatch": "^4.0.3",
54
54
  "@types/ws": "^8.18.1",
55
- "@vitest/snapshot": "^3.2.7",
55
+ "@vitest/snapshot": "^4.1.10",
56
56
  "birpc": "^4.0.0",
57
57
  "picomatch": "^4.0.5",
58
58
  "playwright": "^1.61.1",
59
- "@rstest/core": "0.11.2",
60
- "@rstest/tsconfig": "0.0.1",
61
- "@rstest/browser-ui": "0.0.0"
59
+ "@rstest/browser-ui": "0.0.0",
60
+ "@rstest/core": "0.11.4",
61
+ "@rstest/tsconfig": "0.0.1"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "playwright": "^1.49.1",
65
- "@rstest/core": "^0.11.2"
65
+ "@rstest/core": "^0.11.4"
66
66
  },
67
67
  "peerDependenciesMeta": {
68
68
  "playwright": {
@@ -78,6 +78,7 @@
78
78
  },
79
79
  "scripts": {
80
80
  "build": "rslib build",
81
- "dev": "rslib build --watch"
81
+ "dev": "rslib build --watch",
82
+ "lint": "rslint ."
82
83
  }
83
84
  }
@@ -36,6 +36,7 @@ export async function createBrowserExecutor(
36
36
  const {
37
37
  projects,
38
38
  coverageProvider,
39
+ shardedEntries,
39
40
  freezeShardedEntries,
40
41
  filesOnly,
41
42
  allowEmptyRun,
@@ -90,12 +91,13 @@ export async function createBrowserExecutor(
90
91
  ): Promise<ExecutorCycleOutcome> {
91
92
  const cycle = runBrowserController(context, {
92
93
  projects,
93
- shardedEntries: opts.shardedEntries,
94
+ shardedEntries,
94
95
  freezeShardedEntries,
95
96
  allowEmptyRun,
96
97
  appliedModifyRstestConfigEnvironments,
97
98
  onTraceEvents: opts.onTraceEvents,
98
99
  env: opts.env,
100
+ updateSnapshot: opts.updateSnapshot,
99
101
  });
100
102
  inFlightCycle = cycle;
101
103
  try {
@@ -108,10 +110,10 @@ export async function createBrowserExecutor(
108
110
  inFlightCycle = undefined;
109
111
  }
110
112
  },
111
- async collect(opts): Promise<{ list: ListCommandResult[] }> {
113
+ async collect(): Promise<{ list: ListCommandResult[] }> {
112
114
  const pending = listBrowserTests(context, {
113
115
  projects,
114
- shardedEntries: opts.shardedEntries,
116
+ shardedEntries,
115
117
  freezeShardedEntries,
116
118
  filesOnly,
117
119
  appliedModifyRstestConfigEnvironments,
@@ -16,7 +16,9 @@ import type {
16
16
  import {
17
17
  createBrowserTaskContext,
18
18
  createRstestRuntime,
19
+ formatConsoleArgs,
19
20
  globalApis,
21
+ RSTEST_API_GLOBAL_KEY,
20
22
  RSTEST_ENV_SYMBOL_KEY,
21
23
  setRealTimers,
22
24
  unwrapRegex,
@@ -32,7 +34,6 @@ import {
32
34
  createRunnerLifecycleRequest,
33
35
  sendRunnerLifecycle,
34
36
  } from './dispatchTransport';
35
- import { formatConsoleArgs } from './formatConsole';
36
37
  import { BrowserSnapshotEnvironment } from './snapshot';
37
38
  import {
38
39
  findNewScriptUrl,
@@ -59,6 +60,23 @@ const debugLog = (...args: unknown[]): void => {
59
60
  type RuntimeEnvStore = Record<string, string | undefined>;
60
61
  const RSTEST_ENV_SYMBOL = Symbol.for(RSTEST_ENV_SYMBOL_KEY);
61
62
 
63
+ /**
64
+ * Publish the runtime API on the globals test modules read: the
65
+ * `@rstest/core` external and the `import.meta.rstest` define (node parity:
66
+ * `global['@rstest/core']` in runInPool), plus the `globals: true` API names.
67
+ */
68
+ const installRuntimeGlobals = (
69
+ runtime: Awaited<ReturnType<typeof createRstestRuntime>>,
70
+ runtimeConfig: RuntimeConfig,
71
+ ): void => {
72
+ (globalThis as Record<string, unknown>)[RSTEST_API_GLOBAL_KEY] = runtime.api;
73
+ if (runtimeConfig.globals) {
74
+ for (const apiKey of globalApis) {
75
+ (globalThis as any)[apiKey] = (runtime.api as any)[apiKey];
76
+ }
77
+ }
78
+ };
79
+
62
80
  type GlobalWithRuntimeEnv = typeof globalThis &
63
81
  Record<symbol, unknown> & {
64
82
  global?: typeof globalThis;
@@ -502,12 +520,7 @@ const run = async () => {
502
520
  taskContext: createBrowserTaskContext(),
503
521
  });
504
522
 
505
- // Register global APIs if globals config is enabled
506
- if (runtimeConfig.globals) {
507
- for (const apiKey of globalApis) {
508
- (globalThis as any)[apiKey] = (runtime.api as any)[apiKey];
509
- }
510
- }
523
+ installRuntimeGlobals(runtime, runtimeConfig);
511
524
 
512
525
  try {
513
526
  // Load setup files for this project after runtime is ready.
@@ -636,12 +649,7 @@ const run = async () => {
636
649
 
637
650
  const runtime = await createRstestRuntime(workerState, { taskContext });
638
651
 
639
- // Register global APIs if globals config is enabled
640
- if (runtimeConfig.globals) {
641
- for (const apiKey of globalApis) {
642
- (globalThis as any)[apiKey] = (runtime.api as any)[apiKey];
643
- }
644
- }
652
+ installRuntimeGlobals(runtime, runtimeConfig);
645
653
 
646
654
  let failedTestsCount = 0;
647
655
 
@@ -45,6 +45,12 @@ const ignoredKeyWarnings: Partial<
45
45
  'a fresh context.',
46
46
  browserOnly: true,
47
47
  },
48
+ federation: {
49
+ isNonDefault: (config) => config.federation === true,
50
+ message: () =>
51
+ 'Ignoring federation in browser mode: it only applies to the Node runner.',
52
+ browserOnly: true,
53
+ },
48
54
  detectAsyncLeaks: {
49
55
  isNonDefault: (config) => config.detectAsyncLeaks === true,
50
56
  message: () =>