DOBROMIR HRISTOV
@d_m_hristov
@d_m_hristov
Use a software tool to test another piece of software, comparing the actual outcomes against predicted outcomes.
@d_m_hristov
Too hard
Unexpected failing
Maintenance
Too much time
My code is just awesome
@d_m_hristov
@d_m_hristov
Projects with little or no scope/end goal*
Quick, very short lifespan projects
@d_m_hristov
@d_m_hristov
@d_m_hristov
ESLint, Flow,
TS type check
Jest, Mocha, Jasmine, Ava
Nightwatch, TestCafe,
Puppeteer, Cypress
@d_m_hristov
@d_m_hristov
End-to-end testing is a methodology used to test whether the flow of an application or device is performing as designed from start to finish.
@d_m_hristov
@d_m_hristov
@d_m_hristov
@d_m_hristov
1. Easy installation
npm install cypress && npx cypress open
@d_m_hristov
describe('Checkout', () => {
it('should add a pizza to the cart', () => {
cy.visit('https://marcos-pizza.com')
cy.get('h1')
.should('contain', 'Choose your pizza')
cy.get('.items > .item--pizza')
.contains('pepperoni')
.first()
.click()
cy.get('.cart .cart__items')
.should('have.length', 1)
cy.get('input.address-field')
.type('My home street 1')
cy.get('select.city')
.select('sofia')
cy.get('input.time')
.type(Cypress.moment().hour(18).minute(30).toDate())
cy.get('.cart .next')
.click()
cy.url().should('include','/cart')
})
})
@d_m_hristov
const getStore = () => cy.window().its('$app.$store')
describe('Checkout', () => {
beforeEach(() => {
cy.server()
cy.route('POST','/finish').as('sendPizzas')
})
it('should finish an order from cart', () => {
cy.visit('https://marcos-pizza.com/cart')
cy.request('/api/pizzas').its('responseBody').then(({ data }) => {
const pepperoni = Cypress._.find(data, { 'name': 'Pepperoni' })
cy.get('.cart-items').should('have.length', 0)
getStore().invoke('dispatch', 'addToCart', pepperoni.id)
})
cy.closeAdPopup()
getStore().its('state.cart.items').should('have.length', 1)
cy.getByTestId('CartComplete-Trigger').click()
cy.wait('@sendPizzas')
.its('status')
.should('eql', 200)
cy.contains('Your pizza is on its way')
})
})
@d_m_hristov
5. FREE
@d_m_hristov
@d_m_hristov
@d_m_hristov
@d_m_hristov