Good News About End-to-end Testing

Gleb Bahmutov

Fast, easy and reliable testing for          anything that runs in a browser.

2 years with Cypress

Simple to start

Simple to test complex cases

Simple to run on CI

Simple to do visual testing

Simple to collect code coverage

npm install cypress
npx cypress open
npx @bahmutov/cly init
docker run -it -v $PWD:/e2e -w /e2e \
    cypress/included:3.2.0

Simple to start

it('completes todo', () => {
  // opens TodoMVC running at "baseUrl"
  cy.visit('/')
  cy.get('.new-todo').type('write tests{enter}')
  cy.contains('.todo-list li', 'write tests')
    .find('.toggle').check()
  cy.contains('.todo-list li', 'write tests')
    .should('have.class', 'completed')
})

Simple to test complex cases

version: 2.1
orbs:
  cypress: cypress-io/cypress@1
workflows:
  build:
    jobs:
      - cypress/run

Simple to run on CI

Simple to do visual testing

$ npm install -D @percy/cypress
import '@percy/cypress'
// ...

cypress/support/index.js

cy.percySnapshot('<name>')

1.

2.

3.

Simple to collect code coverage

before(() => {
  cy.task('resetCoverage', 
    { isInteractive: Cypress.config('isInteractive') })
})

afterEach(() => {
  cy.window().then(win => {
    if (win.__coverage__) {
      cy.task('combineCoverage', win.__coverage__)
    }
  })
})

after(() => {
  cy.task('coverageReport')
})

cypress/support/index.js

Good News About End-to-end Testing

Good News about End-to-end Testing

By Gleb Bahmutov

Good News about End-to-end Testing

Have you heard: e2e testing is easy! It is easy to get started, it is easy to write complex tests, it is easy to run on CI, it is easy to do visual testing and it is even easy to collect code coverage.

  • 411
Loading comments...

More from Gleb Bahmutov