Our tests are powered by Jet
Note: instructions in this file assume you're running terminal commands from the root of the project and not from inside the tests directory.
-
Make sure you have Xcode installed (tested with Xcode 15+) to develop iOS items
-
Make sure you have Node.js installed with yarn installed globally (node version 18 and 20 tested,
npm install --global yarn
). -
Make sure you have all required iOS dependencies installed:
-
brew tap wix/brew brew install wix/brew/applesimutils
-
Note: If Homebrew complains about a conflict in the
wix/brew
tap, runbrew untap wix/brew && brew tap wix/brew
and try installing again
You might find yourself in a situation where you want to start from a clean slate. The following will delete all node_modules
and project build
folders.
yarn lerna:clean
yarn build:all:clean
yarn
yarn lerna:prepare
yarn tests:ios:pod:install # for iOS development
Start the React Native packager using the script provided;
yarn tests:packager:jet
⚠️ It must be this script only that starts the RN Packager, using the default RN packager command will not work.
⚠️ Also ensure that all existing packagers are terminated and that you have no React Native debugger tabs open on your browsers.
This packager will automatically rebuild on any JS changes to the library code. You don't need to restart this, leave it running whilst developing.
As always; the first build for each platform will take a while. Subsequent builds are much quicker ⚡️
⚠️ You must rebuild native every time you make changes to native code (anything in /android /iOS directories).
yarn tests:android:build # If on linuxu or macOS, or...
yarn tests:android:build:windows # If you are on windows
yarn tests:ios:build
To run android tests you will need to create a new emulator and name it TestingAVD
(You can't rename existing one).
This emulator will need to be up and running before you start your android tests from Step 5.
With iOS Detox will start a simulator for you by default or run tests in an open one.
For the Firestore emulator you need to install the tools and start the emulator:
yarn tests:emulator:start # for linux/macOS-hosted development, or...
yarn tests:emulator:start:windows # if developing on windows
This action will launch a new simulator (if not already open) and run the tests on it.
💡 iOS by default will background launch the simulator - to have it launch in the foreground make sure any simulator is currently open,
Finder -> Simulator.app
.
💡 Android by default looks for a predefined emulator named
TestingAVD
- make sure you have one named the same setup on Android Studio. Or you can change this name in thepackage.json
of the tests project (don't commit the change though please). DO NOT rename an existing AVD to this name - it will not work, rename does not change the file path currently so Detox will fail to find the AVD in the correct directory. Create a new one with Google Play Services.
yarn tests:android:test
yarn tests:ios:test
The tests:${platform}:test
commands uninstall any existing app and installs a fresh copy. You can
run tests:${platform}:test-reuse
instead if you don't need to re-install the app (i.e only making JS code changes).
Just remember to use test-${platform}
if you made native code changes and rebuilt - after installing once you can
go back to using the reuse
variant.
The tests:${platform}:cover
variant of the yarn scripts will additionally run tests with coverage.
Coverage is output to the root directory of the project: react-native-firebase/coverage
,
open react-native-firebase/coverage/lcov-report/index.html
in your browser after running tests
to view detailed coverage output.
Mocha supports the .only
syntax, e.g. instead of describe(...) || it(...)
you can use describe.only(...) || it.only(...)
to only run that specific context or test.
Another way to do this is via adding a --grep
option to e2e/mocha.opts
file, e.g. --grep auth
for all tests that have auth in the file path or tests descriptions.
💡 Don't forget to remove these before committing your code and submitting a pull request
For more Mocha options see https://mochajs.org/#usage
Runs ESLint and respective type checks on project files
yarn validate:all:js
yarn validate:all:ts
yarn validate:all:flow
Navigate to your .vscode/launch.json.
Ensure the following exists as a debugging option.
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"port": 9229
}
- Add a breakpoint in the JS file where you will need to debug.
- Select the debug icon under 'NPM Scripts' when selecting one of the following scripts...
- tests:ios:test:debug (iOS)
- tests:android:test:debug (Android)
Built and maintained with 💛 by Invertase.
💼 Hire Us | ☕️ Sponsor Us | 💻 Work With Us