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

document commands for cypress e2e tests #3030

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,41 @@ Hook specific assertions:

## Cypress Tests

Cypress is used to run tests against the frontend while mocking all network requests.
Cypress is used to run tests against the frontend by either mocking all network requests or directly interacting with a live cluster.

Single command to run all Cypress tests or a specific test (build frontend, start HTTP server, run Cypress):
### E2E Tests

Cypress e2e tests run 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=./test-variables.yml
```

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`);
```

Prior to running the Cypress e2e tests, run `oc login` to login as a cluster admin to ensure the test env matches that of our CI and provides a default user for all `oc` commands executed in tests.

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
```

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 mocked tests run against a standalone frontend while mocking all network requests.

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
Loading