Use Jest expectations over the Detox custom ones

Viewed 306

Can I use Jest expectations (https://jestjs.io/docs/en/expect) over the Detox ones? Could you please tell me how to do it, if it's possible? I have Jest runner installed

2 Answers

Not possible. Detox expectations are run in the application, rather than the Detox node process.

This is often a hint for applying bad practices, and is generally discouraged. As a rule of thumb, at E2E (UI testing) level, assertions should be done at UI-level.

For example, it is common practice to create a custom in-app test screen that renders the current state of what you're expecting the app be in. Then, the assertion can generally be implemented as a 2-step process:

a. The navigation to that screen test screen, followed by -

b. A node-side expectation using Detox' by.text() & toBeVisible() matching API.

Related