these slides
C / C++ / C# / Java / CoffeeScript / JavaScript / Node / Angular / Vue / Cycle.js / functional / testing
24 people. Atlanta, Philly, Boston, NYC, Nashville,
Myanmar, Colombia, Ukraine
Fast, easy and reliable testing for anything that runs in a browser
NOW
everywhere
image source: http://ktla.com/2016/04/02/small-plane-crashes-into-suv-on-15-freeway-in-san-diego-county/
undefined is not a function
E2E
integration
unit
E2E
integration
unit
E2E
integration
unit
E2E
integration
unit
Really important to users
Really important to developers
npm i -D cypress
docker run cypress/included
or download Cypress application
1
example project: https://github.com/cypress-io/jsnation-example
or use Docker image
2
it('adds and completes todos', () => {
cy.visit('/')
cy.get('.new-todo')
.type('write code{enter}')
.type('write tests{enter}')
.type('deploy{enter}')
cy.get('.todo').should('have.length', 3)
cy.get('.todo').first().find('.toggle')
.check()
cy.get('.todo').first()
.should('have.class', 'completed')
})
3
version: 2.1
orbs:
cypress: cypress-io/cypress@1
workflows:
build:
jobs:
- cypress/run:
# we need to start the web application
start: npm start
{
"scripts": {
"test": "cypress:run",
"start": "parcel serve public/index.html",
"e2e": "start-test 1234"
}
}
Do I need more end-to-end tests?
But do not let 100% code coverage be the only goal
import '@cypress/code-coverage/support'
cypress/support/index.js file
module.exports = (on, config) => {
on('task', require('@cypress/code-coverage/task'))
}
cypress/plugins/index.js file
A single end-to-end test can be very effective at covering a lot of code
The missed lines in the business logic code are targets for more end-to-end tests
Cannot reach the edge case from the end-to-end test
import {getVisibleTodos} from '../../src/selectors'
describe('getVisibleTodos', () => {
it('throws an error for unknown visibility filter', () => {
expect(() => {
getVisibleTodos({
todos: [],
visibilityFilter: 'unknown-filter'
})
}).to.throw()
})
})
cypress/integration/selectors-spec.js
and get a perfect 100%
Does the app work on different screens?
;['macbook-15', 'iphone-6'].forEach(viewport => {
it(`works on ${viewport}`, () => {
cy.viewport(viewport)
cy.visit('/')
cy.get('.new-todo')
.type('write code{enter}')
.type('write tests{enter}')
.type('deploy{enter}')
cy.get('.todo').should('have.length', 3)
cy.get('.todo')
.first()
.find('.toggle')
.check()
cy.get('.todo')
.first()
.should('have.class', 'completed')
cy.get('.clear-completed').click()
cy.get('.todo').should('have.length', 2)
})
})
// import 'todomvc-app-css/index.css'
functional tests still pass!
baseline image
new image
visual diff
🙁 Hard to test complex app states
😍 — but not with Cypress!
😵 Performance
😡 Consistent & deterministic rendering
😬 Day-to-day review process & approval workflow.
Do-It-Yourself vs 3rd party service
Disclaimer: PhD in Computer Vision and Image Processing
runs first
added async
Cypress GitHub integration is coming soon