[DRAFT] Vega - Cypress quick start guide

  1. Clone the repository from: https://github.com/folio-org/stripes-testing
  2. Open it and "yarn" all dependencies (cypress is included).
  3. Сypress already have Node.js in its bundle, we don’t need install it separately.
  4. Write tests in “cypress\integration” folder.
  5. 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 cy.visit() or cy.request() command's URL

env

{}

Any values to be set as environment variables

retries

{

   "runMode": 0,

   "openMode": 0,

}

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 cy.visit(), cy.go(), cy.reload() commands to fire their page load events. Network requests are limited by the underlying operating system, and may still time out if this value is increased.

requestTimeout

5000

Time, in milliseconds, to wait for a request to go out in a cy.wait() command

responseTimeout

30000

Time, in milliseconds, to wait until a response in a cy.request(), cy.wait(), cy.fixture(), cy.getCookie(), cy.getCookies(), cy.setCookie(), cy.clearCookie(), cy.clearCookies(), and cy.screenshot() commands

viewportHeight

660

Default height in pixels for the application under tests' viewport (Override with cy.viewport() command)

viewportWidth

1000

Default width in pixels for the application under tests' viewport. (Override with cy.viewport() command)

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