diff --git a/scripts/generate-react-native-fixture.js b/scripts/generate-react-native-fixture.js index dc391c76d..ff8e08344 100644 --- a/scripts/generate-react-native-fixture.js +++ b/scripts/generate-react-native-fixture.js @@ -18,8 +18,10 @@ const notifierVersion = process.env.NOTIFIER_VERSION || common.determineVersion( const reactNativeVersion = process.env.RN_VERSION const ROOT_DIR = resolve(__dirname, '../') +const isNewArchEnabled = process.env.RCT_NEW_ARCH_ENABLED === 'true' || process.env.RCT_NEW_ARCH_ENABLED === '1' + let fixturePath = 'test/react-native/features/fixtures/generated/' -if (process.env.RCT_NEW_ARCH_ENABLED === '1') { +if (isNewArchEnabled) { fixturePath += 'new-arch/' } else { fixturePath += 'old-arch/' @@ -34,14 +36,6 @@ const DEPENDENCIES = [ `@bugsnag/react-native@${notifierVersion}` ] -const REACT_NAVIGATION_DEPENDENCIES = [ - `@bugsnag/plugin-react-navigation@${notifierVersion}`, - '@react-navigation/native', - '@react-navigation/native-stack', - 'react-native-screens', - 'react-native-safe-area-context' -] - if (!process.env.SKIP_GENERATE_FIXTURE) { // remove the fixture directory if it already exists if (fs.existsSync(fixtureDir)) { @@ -58,7 +52,7 @@ if (!process.env.SKIP_GENERATE_FIXTURE) { } if (process.env.BUILD_ANDROID === 'true' || process.env.BUILD_ANDROID === '1') { - if (process.env.RCT_NEW_ARCH_ENABLED === 'true' || process.env.RCT_NEW_ARCH_ENABLED === '1') { + if (isNewArchEnabled) { // If we're building with the new architecture, replace the gradle.properties file fs.copyFileSync( resolve(replacementFilesDir, 'android/newarch.gradle.properties'), @@ -113,8 +107,11 @@ if (process.env.BUILD_IOS === 'true' || process.env.BUILD_IOS === '1') { execFileSync('xcrun', exportArgs, { cwd: fixtureDir, stdio: 'inherit' }) } -function installFixtureDependencies() { - DEPENDENCIES.push(...REACT_NAVIGATION_DEPENDENCIES) +function installFixtureDependencies () { + if (!isNewArchEnabled) { + const reactNavigationDependencies = getReactNavigationDependencies() + DEPENDENCIES.push(...reactNavigationDependencies) + } const fixtureDependencyArgs = DEPENDENCIES.join(' ') @@ -128,11 +125,11 @@ function installFixtureDependencies() { } /** Replace native files generated by react-native cli with pre-configured files */ -function replaceGeneratedFixtureFiles() { +function replaceGeneratedFixtureFiles () { // replace the App.js/App.tsx file with our own App.js file fs.readdirSync(resolve(fixtureDir)) - .filter((file) => /App\.[tj]sx?$/.test(file)) - .map((file) => fs.unlinkSync(resolve(fixtureDir, file))) + .filter((file) => /App\.[tj]sx?$/.test(file)) + .map((file) => fs.unlinkSync(resolve(fixtureDir, file))) fs.copyFileSync( resolve(replacementFilesDir, 'App.js'), @@ -220,4 +217,23 @@ class MainActivity : ReactActivity() { let mainActivityContents = fs.readFileSync(mainActivityPath, 'utf8') mainActivityContents = mainActivityContents.replace(mainActivityPattern, mainActivityReplacement) fs.writeFileSync(mainActivityPath, mainActivityContents) -} \ No newline at end of file +} + +function getReactNavigationDependencies () { + let reactNativeScreensVersion + switch (reactNativeVersion) { + case '0.71': + reactNativeScreensVersion = '3.32.0' + break; + default: + reactNativeScreensVersion = 'latest' + } + + return [ + `@bugsnag/plugin-react-navigation@${notifierVersion}`, + '@react-navigation/native', + '@react-navigation/native-stack', + `react-native-screens@${reactNativeScreensVersion}`, + 'react-native-safe-area-context' + ] +} diff --git a/test/react-native/features/navigation.feature b/test/react-native/features/navigation.feature index 5ddcae29b..335427dfd 100644 --- a/test/react-native/features/navigation.feature +++ b/test/react-native/features/navigation.feature @@ -1,4 +1,4 @@ -@navigation +@navigation @skip_new_arch Feature: Navigation plugin features Scenario: Navigating screens causes breadcrumbs and context to be updated