Skip to content

Commit

Permalink
skip react navigation tests on new arch
Browse files Browse the repository at this point in the history
  • Loading branch information
yousif-bugsnag committed Sep 18, 2024
1 parent a09db1d commit 1bbff63
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
48 changes: 32 additions & 16 deletions scripts/generate-react-native-fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Expand All @@ -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)) {
Expand All @@ -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'),
Expand Down Expand Up @@ -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(' ')

Expand All @@ -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'),
Expand Down Expand Up @@ -220,4 +217,23 @@ class MainActivity : ReactActivity() {
let mainActivityContents = fs.readFileSync(mainActivityPath, 'utf8')
mainActivityContents = mainActivityContents.replace(mainActivityPattern, mainActivityReplacement)
fs.writeFileSync(mainActivityPath, mainActivityContents)
}
}

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'
]
}
2 changes: 1 addition & 1 deletion test/react-native/features/navigation.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@navigation
@navigation @skip_new_arch
Feature: Navigation plugin features

Scenario: Navigating screens causes breadcrumbs and context to be updated
Expand Down

0 comments on commit 1bbff63

Please sign in to comment.