Skip to content

Commit

Permalink
document commands for cypress e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvogt committed Jul 23, 2024
1 parent b909563 commit 9c771f9
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,37 @@ Hook specific assertions:

## Cypress Tests

### E2E Tests

Cypress is used to run tests against a live cluster.

Before running the Cypress e2e tests, you must populate the test variables by first creating a copy of the `test-variables.yml.example` file and setting the `CY_TEST_CONFIG` env variable value to be the path to this file. Update the variables according to your testing environment.

```bash
CY_TEST_CONFIG=~/dev/test-variables.yml`
```

To run all Cypress e2e tests, a specific test, or open the Cypress GUI:
```bash
npm run cypress:run
npm run cypress:run -- --spec "**/testfile.cy.ts"
npm run cypress:open
```

Cypress e2e tests can make use of the `oc` command line tool. This is useful for test setup and tear down. When run in CI, the default user will be a cluster admin.
```ts
cy.exec(`oc new-project test-project`);
```

Use the custom command `cy.visitWithLogin` to visit a page and perform the login procedure steps if the user is not already logged in. The default user is not an ODH admin. `cy.visitWithLogin` can be used to login with different users by supplying the user auth configuration as a parameter.

### Mocked Tests

Cypress is used to run tests against the frontend while mocking all network requests.

Single command to run all Cypress tests or a specific test (build frontend, start HTTP server, run Cypress):
Single command to run all Cypress mock tests or a specific test (build frontend, start HTTP server, run Cypress):
```bash
npm run test:cypress-ci
Expand Down

0 comments on commit 9c771f9

Please sign in to comment.