Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 966 Bytes

File metadata and controls

32 lines (25 loc) · 966 Bytes

Adding Cypress to an existing project

  1. Install Cypress and start-server-and-test: $ npm install -D cypress start-server-and-test @testing-library/cypress

  2. add some scripts to the package.json

"cy:open":"cypress open",
"cy:run":"cypress run"
  1. delete cypress/integration/examples

  2. 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('/')
  })
});
  1. edit the cypress.json adding the baseUrl ("baseUrl": "http://localhost:<YOUR_PORT>",)

  2. 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