diff --git a/.env.example b/.env.example index d4db46ab97..5cf8e07b1c 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,6 @@ +# Copy this to `.env` and `.env.test` files + SENTRY_AUTH_TOKEN= +EXPO_PUBLIC_ENV=development EXPO_PUBLIC_LOG_LEVEL=debug EXPO_PUBLIC_LOG_DEBUG= diff --git a/docs/testing.md b/docs/testing.md index 123c58ebc8..e9b9445e04 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -1,5 +1,8 @@ # Testing instructions +Make sure you've copied `.env.example` to `.env.test` and provided any required +values. + ### Using Maestro E2E tests 1. Install Maestro by following [these instructions](https://maestro.mobile.dev/getting-started/installing-maestro). This will help us run the E2E tests. 2. You can write Maestro tests in `__e2e__/maestro` directory by creating a new `.yaml` file or by modifying an existing one. @@ -11,4 +14,4 @@ 2. Install Flashlight by following [these instructions](https://docs.flashlight.dev/) 3. The simplest way to get started is by running `yarn perf:measure` which will run a live preview of the performance test results. You can [see a demo here](https://github.com/bamlab/flashlight/assets/4534323/4038a342-f145-4c3b-8cde-17949bf52612) 4. The `yarn perf:test:measure` will run the `scroll.yaml` test located in `__e2e__/maestro/scroll.yaml` and give the results in `.perf/results.json` which can be viewed by running `yarn:perf:results` -5. You can also run your own tests by running `yarn perf:test ` where `` is the path to your test file. For example, `yarn perf:test __e2e__/maestro/scroll.yaml` will run the `scroll.yaml` test located in `__e2e__/maestro/scroll.yaml`. \ No newline at end of file +5. You can also run your own tests by running `yarn perf:test ` where `` is the path to your test file. For example, `yarn perf:test __e2e__/maestro/scroll.yaml` will run the `scroll.yaml` test located in `__e2e__/maestro/scroll.yaml`. diff --git a/index.js b/index.js index 4fc95bd17b..7630d0538a 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,21 @@ import 'react-native-gesture-handler' // must be first - import {LogBox} from 'react-native' -LogBox.ignoreLogs(['Require cycle:']) // suppress require-cycle warnings, it's fine import '#/platform/polyfills' +import {IS_TEST} from '#/env' import {registerRootComponent} from 'expo' import {doPolyfill} from '#/lib/api/api-polyfill' -doPolyfill() import App from '#/App' +doPolyfill() + +if (IS_TEST) { + LogBox.ignoreAllLogs() // suppress all logs in tests +} else { + LogBox.ignoreLogs(['Require cycle:']) // suppress require-cycle warnings, it's fine +} + // registerRootComponent calls AppRegistry.registerComponent('main', () => App); // It also ensures that whether you load the app in Expo Go or in a native build, // the environment is set up appropriately diff --git a/package.json b/package.json index 7a6efcd05e..eae6ebe6eb 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ "lint": "eslint ./src --ext .js,.jsx,.ts,.tsx", "typecheck": "tsc --project ./tsconfig.check.json", "e2e:mock-server": "./jest/dev-infra/with-test-redis-and-db.sh ts-node __e2e__/mock-server.ts", - "e2e:metro": "RN_SRC_EXT=e2e.ts,e2e.tsx expo run:ios", - "e2e:build": "detox build -c ios.sim.debug", - "e2e:run": "detox test --configuration ios.sim.debug --take-screenshots all", + "e2e:metro": "NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo run:ios", + "e2e:build": "NODE_ENV=test detox build -c ios.sim.debug", + "e2e:run": "NODE_ENV=test detox test --configuration ios.sim.debug --take-screenshots all", "perf:test": "NODE_ENV=test maestro test", "perf:test:run": "NODE_ENV=test maestro test __e2e__/maestro/scroll.yaml", "perf:test:measure": "NODE_ENV=test flashlight test --bundleId xyz.blueskyweb.app --testCommand 'yarn perf:test' --duration 150000 --resultsFilePath .perf/results.json", diff --git a/src/env.ts b/src/env.ts index 7b255e7ea6..fbcc15f576 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,4 +1,4 @@ -export const IS_TEST = process.env.NODE_ENV === 'test' +export const IS_TEST = process.env.EXPO_PUBLIC_ENV === 'test' export const IS_DEV = __DEV__ export const IS_PROD = !IS_DEV export const LOG_DEBUG = process.env.EXPO_PUBLIC_LOG_DEBUG || ''