Skip to content

Commit cc72bee

Browse files
rubennortefacebook-github-bot
authored andcommitted
Restore Fantom DevTools launching with FANTOM_DEBUG_JS (#59410)
Summary: Restore DevTools launching when `FANTOM_DEBUG_JS` is set by allowing the existing native tester to launch through the shared browser launcher. Explicitly allow app launching for interactive test debugging, use a Chrome app window instead of the standalone shell, and run debugging sessions in band. Changelog: [Internal] Reviewed By: lenaic, andrewdacenko Differential Revision: D127171074
1 parent 54b5f22 commit cc72bee

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

‎packages/dev-middleware/src/utils/DefaultToolLauncher.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ const {apps, openApp} = open;
2323
* local machine.
2424
*/
2525
const DefaultToolLauncher = {
26-
launchDebuggerAppWindow: async (url: string): Promise<void> => {
27-
if (process.env.NODE_ENV === 'test') {
26+
launchDebuggerAppWindow: async (
27+
url: string,
28+
options?: Readonly<{
29+
allowInTests?: boolean,
30+
}>,
31+
): Promise<void> => {
32+
if (process.env.NODE_ENV === 'test' && options?.allowInTests !== true) {
2833
assertMockedInTests();
2934
}
3035

‎private/react-native-fantom/runner/global-setup/globalSetup.js‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010

1111
import type {DevToolLauncher} from '@react-native/dev-middleware';
1212

13-
import {isOSS, validateEnvironmentVariables} from '../EnvironmentOptions';
13+
import {
14+
debugJS,
15+
isOSS,
16+
validateEnvironmentVariables,
17+
} from '../EnvironmentOptions';
1418
import {getTestBuildOutputPath} from '../paths';
1519
import build from './build';
16-
import {createDevMiddleware} from '@react-native/dev-middleware';
20+
import {
21+
createDevMiddleware,
22+
unstable_DefaultToolLauncher as DefaultToolLauncher,
23+
} from '@react-native/dev-middleware';
1724
import * as Metro from 'metro';
1825
import {Server} from 'node:net';
1926
import path from 'node:path';
@@ -55,19 +62,26 @@ async function startMetroServer() {
5562
// $FlowExpectedError[cannot-write]
5663
metroConfig.server.port = Number(process.env.__FANTOM_METRO_PORT__);
5764

58-
// No-op app launcher to prevent debugger-shell launches during tests
65+
const serverBaseUrl = `http://localhost:${metroConfig.server.port}`;
5966
const devToolLauncher: DevToolLauncher = {
60-
launchDebuggerAppWindow: async (_url: string) => {},
61-
launchDebuggerShell: async () => {},
62-
prepareDebuggerShell: async () => ({code: 'not_implemented'}),
67+
launchDebuggerAppWindow: async (url: string) => {
68+
if (debugJS) {
69+
await DefaultToolLauncher.launchDebuggerAppWindow(url, {
70+
allowInTests: true,
71+
});
72+
}
73+
},
6374
};
6475

6576
const {
6677
middleware: devMiddleware,
6778
websocketEndpoints: debuggerWebsocketEndpoints,
6879
} = createDevMiddleware({
69-
serverBaseUrl: `http://localhost:${metroConfig.server.port}`,
80+
serverBaseUrl,
7081
unstable_toolLauncher: devToolLauncher,
82+
unstable_experiments: {
83+
enableStandaloneFuseboxShell: false,
84+
},
7185
});
7286

7387
const server = await Metro.runServer(metroConfig, {

‎scripts/fantom.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ for arg in "$@"; do
3333
esac
3434
done
3535

36-
if [[ -n "$FANTOM_RUN_BENCHMARKS" ]]; then
36+
if [[ -n "$FANTOM_RUN_BENCHMARKS" || -n "$FANTOM_DEBUG_JS" ]]; then
3737
ARGS+=("--runInBand")
3838
fi
3939

0 commit comments

Comments
 (0)