-
Install Cypress and start-server-and-test:
$ npm install -D cypress start-server-and-test @testing-library/cypress
-
add some scripts to the package.json
"cy:open":"cypress open",
"cy:run":"cypress run"
-
delete cypress/integration/examples
-
create a smoke test: create a
cypres/integration/smoke.spec.js
file containing the following content code
/// <reference types="Cypress" />
context('smoke', () => {
it('Should work', ()=>{
cy.visit('/')
})
});
-
edit the
cypress.json
adding the baseUrl ("baseUrl": "http://localhost:<YOUR_PORT>",
) -
add the
test
script to the package.json
"test": "start-server-and-test start http://localhost:<YOUR_PORT> cy:run",
That's it! You're ready to:
- launch
$ npm run cy:open
that allows to use Cypress locally - launch
$ npm test
that allows to start the application and test it in CI pipelines