...
A /cypress directory has been created. It contains the following sub-directories.
/downloads - for files downloaded during a test. Not yet used.
/e2e - this is where all of our E2E integration tests go. All tests follow the format exampleTest.cy.ts.
/fixtures - for Cypress fixtures.
/screenshots - Cypress automatically saves screenshots it takes from the tests to this location. These are not to be committed to Git, but are sometimes useful for evidencing test failures or diagnosing an issue. Add this directory to your .gitignore file.
/support - contains configuration files for Cypress such as e2e.ts, which manages config for E2E tests, and commands.ts, which is where Cypress custom commands are registered.
An example of a custom command is cy.login() - as we generally have to login at the start of most tests, refactoring the necessary code into a command makes sense.
/utils - holds any required utility functions.
Also located within this directory is the Cypress tsconfig.json file, which regulates the behaviour of the TypeScript compiler when dealing with Cypress files.
Outside of this directoryAt the root of the project, cypress.config.ts manages global Cypress configuration settings.
Before doing anything with Cypress, you will need to add a CYPRESS_USER and CYPRESS_PW to your create a
These values should correspond to the username and password you currently use to log in to DCB Admin, as they will be used by Cypress to login to DCB Admin for its testscypress.env.json
file at the root of the project (same level aspackage.
json
) and add the following:Code Block { "NEXTAUTH_JWT_SECRET": "jkdhfkjsahfdjkhsdkjf73" }
This provides the NextAuth secret to Cypress, which enables it to create the NextAuth cookies necessary for simulating login.
Preparing and writing tests
...