Skip to main content

Writing End-To-End and Integration Tests

We run integration tests for both the NodeJS and React Native reference implementation using Cypress. You can find the set up and source code for these tests in ./test/e2e/run.sh. In principle, we start Ory Kratos with some configuration and an in-memory database in the background

DSN=memory hydra serve -c ./path/to/config/kratos.yml --dev > "kratos.e2e.log" 2>&1 &

as well as our application in the background as well. Then, we start the Cypress test runner which executes the different e2e tests. This works really well to test compliance and integration of Ory Kratos.

If you run Ory Kratos and your app on separate domains or ports you might want to add

{
"chromeWebSecurity": false
}

to your cypress.json config file.

Testing React Native on Web with Cypress

If you want to test React Native (rendered as a web application) in Cypress, you need to disable security features preventing browser from executing self-service API flows. To do this, set the environment variable DEV_DISABLE_API_FLOW_ENFORCEMENT=1:

DSN=memory \
DEV_DISABLE_API_FLOW_ENFORCEMENT=true
hydra serve -c ./path/to/config/kratos.yml --dev > "kratos.e2e.log" 2>&1 &)