[DRAFT] Vega - Cypress quick start guide
- Clone the repository from: https://github.com/folio-org/stripes-testing
- Open it and "yarn" all dependencies (cypress is included).
- Сypress already have Node.js in its bundle, we don’t need install it separately.
- Write tests in “cypress\integration” folder.
- How to start tests:
"test:cypress:snapshot"
– start tests using snapshot env."test:cypress:local"
– start tests using your local modules state."test:cypress:yakbak"
– start tests with cached response data.
Example of run command:
cypress run --config baseUrl=https://folio-snapshot.dev.folio.org
For additional abilities to run tests check package.json "scripts" section.
You can execute "cypress open" to open cypress UI where you will be able run test one by one or full suit of tests, see the "real-time" result and debug tests.
If you want to run a single file with tests, you can use:
cypress run --spec "cypress/integration/testForRun.spec.js"
Also we have the ability to choose which tests in file will or will not run:
- To skip test we can use "
it.skip()
" or "xit()
" – that tests will marked by cypress as pending. - Also cypress don’t execute empty tests "
it('is not written yet')
" and mark them as pending - If we want to run only one test from test suit we can use "
it.only()
" syntax.
Main options that you can use:
Option | Default | Description |
baseUrl | Null | URL used as prefix for |
env | {} | Any values to be set as environment variables |
retries |
| The number of times to retry a failing test. Can be configured to apply to cypress run or cypress open separately. |
watchForFileChanges | true | Whether Cypress will watch and restart tests on test file changes |
defaultCommandTimeout | 4000 | Time, in milliseconds, to wait until most DOM based commands are considered timed out |
pageLoadTimeout | 60000 | Time, in milliseconds, to wait for page transition events or |
requestTimeout | 5000 | Time, in milliseconds, to wait for a request to go out in a |
responseTimeout | 30000 | Time, in milliseconds, to wait until a response in a |
viewportHeight | 660 | Default height in pixels for the application under tests' viewport (Override with |
viewportWidth | 1000 | Default width in pixels for the application under tests' viewport. (Override with |
waitForAnimations | true | Whether to wait for elements to finish animating before executing commands |
scrollBehavior | top | Viewport position to which an element should be scrolled before executing commands. Can be 'center', 'top', 'bottom', 'nearest', or false. false disables scrolling. |
nodeVersion | bundled | If set to system, Cypress will try to find a Node executable on your path to use when executing your plugins. Otherwise, Cypress will use the Node version bundled with Cypress. |
./cypress.json – default path and name of cypress config file.
For more info about settings: https://docs.cypress.io/guides/references/configuration
Also you can setup few config files and run cypress with one of it with "--config-file
" flag with path to config file after it.
On FOLIO we prefer to use interactors for stripes components instead of cypress build in tools. Interactors are located in ./interactors folder.
Validate approach described in /wiki/spaces/DQA/pages/2659674.
More info about interactors you can find here: https://frontside.com/interactors.
Best practices: https://docs.cypress.io/guides/references/best-practices