Skip to content
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

Merged
merged 1 commit into from
Oct 5, 2017
Merged

Docs: Jest usage #315

merged 1 commit into from
Oct 5, 2017

Conversation

DanielMSchmidt
Copy link
Contributor

Heavily inspired by the solution of @AlanFoster and with the help of @levito

@DanielMSchmidt DanielMSchmidt force-pushed the docs/jest-integration branch 3 times, most recently from f0962a1 to af20ca4 Compare October 5, 2017 09:05
Add this part to your `package.json`:
```json
"scripts": {
"test:e2e": "jest e2e --setupTestFrameworkScriptFile=./jest/setup-e2e-tests.js"
Copy link

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"
  },

Copy link
Contributor Author

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

Copy link

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

@rotemmiz
Copy link
Member

rotemmiz commented Oct 5, 2017

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.

@rotemmiz
Copy link
Member

rotemmiz commented Oct 5, 2017

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...)

@DanielMSchmidt DanielMSchmidt force-pushed the docs/jest-integration branch 2 times, most recently from 5fe6d71 to 4851804 Compare October 5, 2017 14:55
@DanielMSchmidt
Copy link
Contributor Author

@rotemmiz Noted the exposure of expect and so on
@chirag04 Thanks for the note, but this was intentional to have test run side by side with the unit tests

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
Copy link
Member

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
@DanielMSchmidt
Copy link
Contributor Author

@rotemmiz I will merge this, implemented your wish. Feel free to edit and improve 👍

@DanielMSchmidt DanielMSchmidt merged commit b398ce1 into master Oct 5, 2017
@DanielMSchmidt DanielMSchmidt deleted the docs/jest-integration branch October 5, 2017 19:24
@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants