Skip to content

Commit 2becf0b

Browse files
adhorodyskiclaude
andcommitted
test(e2e): web target is the Expo app's Metro web export
Replaces the Vite app in example/web. `expo export -p web` in test mode, served by `expo serve` on 4173; same scenarios and goldens. babel-preset-expo keeps native async on web, so example-expo/babel.config.js lowers it for the web platform; metro.config.js maps react-native-nitro-modules to a stub on web. event-emitter-listener now runs on web too (Metro bundles have `require`); its web golden equals the js one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7863902 commit 2becf0b

14 files changed

Lines changed: 121 additions & 107 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ jobs:
433433
if-no-files-found: ignore
434434
include-hidden-files: true # verify/e2e/.e2e is a dot dir
435435

436-
# The bare example's ScenariosScreen through react-native-web and the web SDK (example/web), headless Chromium.
437-
# The runner builds the Vite app in test mode and serves it (e2e.config.ts `command`).
436+
# The Expo app's Metro web export (react-native-web) and the web SDK, headless Chromium.
437+
# The runner exports the app in test mode and serves it (e2e.config.ts `command`).
438438
e2e-web:
439439
runs-on: ubuntu-latest
440440
timeout-minutes: 15
@@ -445,7 +445,7 @@ jobs:
445445
bun-version: 1.2.19
446446
- run: bun install --frozen-lockfile
447447
- run: bun install --frozen-lockfile
448-
working-directory: example
448+
working-directory: example-expo
449449
- run: bun run prepare # the web app resolves the package through exports -> lib/ (browser condition)
450450
- run: bunx e2e-web install chromium --with-deps
451451
- run: bun verify --e2e e2e

‎example-expo/babel.config.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
// The bare example's inline OTEL_TEST_MODE plugin (test mode is a bundle-time flag).
22
const inlineTestMode = require('../example/inlineTestMode');
33

4-
module.exports = {
5-
presets: ['babel-preset-expo'],
6-
plugins: [inlineTestMode],
4+
module.exports = api => {
5+
// babel-preset-expo keeps native async on web, which the context patch cannot see through: lower it (README)
6+
const web = api.caller(c => c?.platform === 'web');
7+
return {
8+
presets: ['babel-preset-expo'],
9+
plugins: [
10+
inlineTestMode,
11+
...(web ? ['@babel/plugin-transform-async-generator-functions', '@babel/plugin-transform-async-to-generator'] : []),
12+
],
13+
};
714
};

‎example-expo/bun.lock‎

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎example-expo/metro.config.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const config = {
1919
nodeModulesPaths: [path.join(__dirname, 'node_modules'), path.join(root, 'node_modules')],
2020
blockList: [...block(root), ...block(path.join(root, 'example'))],
2121
extraNodeModules: {...Object.fromEntries(single.map(m => [m, own(m)])), 'react-native-open-telemetry': root},
22+
// web has no Nitro: ScenariosScreen's HybridObject lookups find none
23+
resolveRequest: (ctx, name, platform) =>
24+
platform === 'web' && name === 'react-native-nitro-modules'
25+
? {type: 'sourceFile', filePath: path.join(__dirname, 'nitro-stub.web.ts')}
26+
: ctx.resolveRequest(ctx, name, platform),
2227
},
2328
};
2429

‎example-expo/package.json‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
"main": "index.js",
66
"scripts": {
77
"postinstall": "test -e node_modules/react-native-open-telemetry || ln -sfn ../.. node_modules/react-native-open-telemetry",
8-
"prebuild": "expo prebuild --clean --no-install"
8+
"prebuild": "expo prebuild --clean --no-install",
9+
"web:e2e": "expo export -p web --clear && expo serve --port 4173"
910
},
1011
"dependencies": {
12+
"@expo/metro-runtime": "~58.0.17",
1113
"expo": "58.0.26",
1214
"react": "19.3.0",
15+
"react-dom": "19.3.0",
1316
"react-native": "0.88.1",
14-
"react-native-nitro-modules": "0.37.2"
17+
"react-native-nitro-modules": "0.37.2",
18+
"react-native-web": "^0.21.4"
1519
}
1620
}

0 commit comments

Comments
 (0)