-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: setup cypress dependency & environment
- Loading branch information
Showing
9 changed files
with
1,438 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000", | ||
"video": false, | ||
"env": { | ||
"dhis2DataTestPrefix": "dhis2-maintenance", | ||
"networkMode": "live", | ||
"dhis2ApiVersion": "40" | ||
}, | ||
"experimentalInteractiveRunEvents": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('Smoke test', () => { | ||
it('should load the app without any errors', () => { | ||
cy.visitAndLoad('/') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { | ||
networkShim, | ||
chromeAllowXSiteCookies, | ||
} = require('@dhis2/cypress-plugins') | ||
|
||
module.exports = (on, config) => { | ||
networkShim(on) | ||
chromeAllowXSiteCookies(on) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { enableAutoLogin, enableNetworkShim } from '@dhis2/cypress-commands' | ||
import './visit-and-load.js' | ||
|
||
enableAutoLogin() | ||
enableNetworkShim() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Cypress.Commands.add('visitAndLoad', (...args) => { | ||
cy.visit(...args) | ||
cy.get('.selector-bar-item').should('exist') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Setting up & running cypress tests | ||
|
||
## Prerequisites | ||
|
||
In order to run cypress tests, a `cypress.env.json` is required in the root | ||
directory. This file is ignored by git on purpose so we don't end up storing | ||
credentials in the public repository. | ||
|
||
The file has to look like this: | ||
|
||
```json | ||
{ | ||
"dhis2BaseUrl": "https://debug.dhis2.org/dev", | ||
"dhis2Username": "system", | ||
"dhis2Password": "System123" | ||
} | ||
``` | ||
|
||
## Working on cypress tests | ||
|
||
The easiest way to work on cypress tests is by starting the app's start script | ||
and the cypress open script independently. There are situations where the | ||
cypress UI has to be restarted and it's more convenient to not have to wait for | ||
the UI as well: | ||
|
||
* In one terminal, run `yarn cypress:start` | ||
* In another terminal, run `yarn cypress:open:live` | ||
|
||
### Checking whether capturing & stubbing requests work | ||
|
||
As this can be a time consuming task, similarly to working on cypress tests, | ||
there are scripts that expect the app to be running already instead of starting | ||
it as well: | ||
|
||
* `yarn cypress:run:capture`: Will run the tests and record all network | ||
requests | ||
* `yarn cypress:run:stub`: Will run the tests and use the recorded requests | ||
|
||
## Capturing & replaying network requests | ||
|
||
When done working on a branch, you can: | ||
|
||
* run `yarn cypress:capture` to generate network fixtures | ||
* run `yarn cypress:stub` to test whether the app works with the generated | ||
fixtures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.