e2e cypress test examples for local news
- npm install
- npm run cypress:open
- Cypress will open and detect all test suites in cypress integration. Double click a test suite to run
https://docs.cypress.io/guides/overview/why-cypress.html# https://docs.cypress.io/api/introduction/api.html#
Cypress makes things easier a bit in regards to flake. Cypress has a visual UI that runs in the browser that we can use to debug and flakey tests. These guides contain some good tips on writing reliable tests. https://docs.cypress.io/guides/references/best-practices.html https://docs.cypress.io/guides/guides/network-requests.html#Flake
As part of the CI process the tests are running inside a docker container that uses the official cypress Debian image https://github.com/cypress-io/cypress-docker-images/tree/master/browsers/chrome63-ff57
docker build -t cypress-test:latest .
docker run --rm -v `pwd`:/usr/local/bbc -t cypress-test:latest bash -lc "cypress run"
We block all requests to the fig redirect route in the cyprss.config file to stop redirects from international locations. This redirect happens as part of the CI process because the jenkins server is in Ireland
We can pass in enviorment variables into cypress by suing the --env parameter when running cypress:
cypress run -s cypress/integration/topic_page.spec.js --env buildnumber=$RELEASEVERSION,testnumber=$BUILDNUMBER,cosmoscertpath=/etc/pki/tls/certs/client.crt,cosmoskeypath=/etc/pki/tls/private/client.key
we can then access them by using
Cypress.env("buildNumber")