This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): Add optional Detox end-to-end tests (#146 by @robinheinze)
[skip ci]
- Loading branch information
1 parent
bedf447
commit 77d714b
Showing
12 changed files
with
262 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"presets": ["module:metro-react-native-babel-preset"], | ||
"env": { | ||
"production": { | ||
} | ||
}, | ||
"plugins": [ | ||
[ | ||
"transform-inline-environment-variables", | ||
{ | ||
"include": ["NODE_ENV", "API"] | ||
} | ||
], | ||
[ | ||
"@babel/plugin-proposal-decorators", | ||
{ | ||
"legacy": true | ||
} | ||
], | ||
[ | ||
"@babel/plugin-proposal-optional-catch-binding" | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Detox End-To-End Testing | ||
|
||
## Setup | ||
|
||
To get your Detox tests up and running, you'll need to install some global dependencies: | ||
|
||
1. Install the latest version of [Homebrew](https://brew.sh/) | ||
2. Make sure you have Node installed (at least 8.6.0). If you don't: | ||
|
||
If you use NVM: | ||
```bash | ||
nvm install node | ||
``` | ||
|
||
Or if you'd prefer to install directly from Homebrew | ||
```bash | ||
brew update && brew install node | ||
``` | ||
|
||
|
||
3. Install `applesimutils, which will allow Detox to communicate with the iOS simulator: | ||
|
||
```bash | ||
brew tap wix/brew && brew install applesimutils | ||
``` | ||
|
||
4. Install the Detox CLI | ||
|
||
```bash | ||
yarn global add detox-cli | ||
``` | ||
|
||
## Adding tests | ||
|
||
We've gotten you started with `./e2e/firstTest.spec.js`, which tests that the two main example screens render properly. | ||
|
||
Note that in order to pick up elements by ID, we've added the `testID` prop to the component. | ||
|
||
## Running tests | ||
|
||
1. Start the packager | ||
|
||
``` | ||
yarn start | ||
``` | ||
|
||
2. Run the app | ||
|
||
In a separate terminal window from the packager: | ||
|
||
``` | ||
yarn build:e2e | ||
``` | ||
|
||
3. Run the tests | ||
|
||
``` | ||
yarn test:e2e | ||
``` | ||
|
||
For more information, make sure to check out the official [Detox Docs](https://github.com/wix/Detox/blob/master/docs/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"setupFilesAfterEnv": ["./init.js"], | ||
"testEnvironment": "node" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// For more info on how to write Detox tests, see the official docs: | ||
// https://github.com/wix/Detox/blob/master/docs/README.md | ||
|
||
describe('Example', () => { | ||
beforeEach(async () => { | ||
await device.reloadReactNative(); | ||
}); | ||
|
||
it('should have welcome screen', async () => { | ||
await expect(element(by.id("FirstExampleScreen"))).toBeVisible(); | ||
}); | ||
|
||
it('should go to next screen after tap', async () => { | ||
await element(by.id('next-screen-button')).tap(); | ||
await expect(element(by.id('SecondExampleScreen'))).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const detox = require('detox'); | ||
const config = require('../package.json').detox; | ||
const adapter = require('detox/runners/jest/adapter'); | ||
|
||
jest.setTimeout(120000); | ||
jasmine.getEnv().addReporter(adapter); | ||
|
||
beforeAll(async () => { | ||
await detox.init(config); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await adapter.beforeEach(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await adapter.afterAll(); | ||
await detox.cleanup(); | ||
}); |
Oops, something went wrong.