-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Jest usage #315
Docs: Jest usage #315
Conversation
f0962a1
to
af20ca4
Compare
docs/Guide.Jest.md
Outdated
Add this part to your `package.json`: | ||
```json | ||
"scripts": { | ||
"test:e2e": "jest e2e --setupTestFrameworkScriptFile=./jest/setup-e2e-tests.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how you can define jest config in your package.json so you don't have to pass in --setupTestFrameworkScriptFile
. Just making a note. either way is fine.
"jest": {
"bail": true,
"setupTestFrameworkScriptFile": "<rootDir>/jest/setup.js"
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional because we wanted to make sure that they run side by side with your normal unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. either way is fine. you can push that logic in setup file too: https://github.com/grabbou/react-native-detox-example/blob/master/jest/setup.js#L10-L14
I would add a note re Detox that it exports expect, waitFor, element and by, so Jest users might find themselves using a different expect object implicitly. |
BTW, we plan on adding another detox.init flavour/flag that will not export all that into globals, and users would need to explicitly import it. It would make lots of sense for Jest. That might be an AWESOME opportunity for a PR (anyone? hint hint...) |
5fe6d71
to
4851804
Compare
docs/Guide.Jest.md
Outdated
There are some things you should notice: | ||
|
||
- Don't worry about mocks being used, detox works on the compiled version of your app. | ||
- Detox exposes it's primitives (`expect`, `device`, ...) globally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detox exposes it's primitives (expect
, device
, ...) globally, it will override Jest's global expect
object.
Closes #143 Heavily inspired by the solution of @AlanFoster and with the help of @levito
4851804
to
5eafcc5
Compare
@rotemmiz I will merge this, implemented your wish. Feel free to edit and improve 👍 |
Heavily inspired by the solution of @AlanFoster and with the help of @levito