it is a blurry line between types of tests, often you will not be able to distinguish integration vs e2e test
I want to be confident that the code I'm writing for the future won't break the app that I have running in production today — Kent C Dodds
A helper robot that behaves like a user to click around the app and verify that it functions correctly.
npm install cypress --save-dev
npx cypress open
describe('My First Test', () => { it('clicking "type" navigates to a new url', () => { cy.visit('https://example.cypress.io'); cy.contains('type').click(); // Should be on a new URL which includes '/commands/actions' cy.url().should('include', '/commands/actions'); }); });
describe('Authorization', () => { it('should encourage more protected passwords', () => { cy.visit('/login'); // <- Arrange cy.get('[name="password"]').type('umbrella'); // <- Act cy.contains('Weak password'); // <- Assert }); });
https://docs.cypress.io/api/commands
cy.visit('http://localhost:3000')
cy.get('.list > li')
cy.get('.article').find('footer')
cy.contains('Hello')
cy.get('.menu-item').trigger('mouseover')
cy.intercept('POST', '/register', { statusCode: 200 })
cy.get(':checkbox').should('be.disabled')
cy.get('.list').within(() => {})
Write tests. Not too many. Mostly integration.— Guillermo Rauch (@rauchg) December 10, 2016
Write tests. Not too many. Mostly integration.
Rule of diminishing returns
is just a starting point and a helper tool, not a goal
=============================== Coverage summary =============================== Statements : 96.23% ( 919/955 ) Branches : 87.75% ( 308/351 ) Functions : 93.71% ( 268/286 ) Lines : 96.16% ( 877/912 ) ================================================================================
A highly unlikely error, writing test for it isn't hard, but just not necessary
cy.wait(1000)
cy.get([data-qa="submit-button"])
skip
cy.get(button).then(() => {})