Skip to content

Instantly share code, notes, and snippets.

View axle07's full-sized avatar

Alex axle07

  • Nikola
  • Phoenix, AZ
View GitHub Profile
@axle07
axle07 / cypress_xhr.js
Created March 15, 2018 18:23
Cypress.js: Assert that an XHR POST was successful.
describe('XHR form submission test', () => {
before(() => {
cy.visit('/testurl')
})
it('successfully submits an XHR on form submission', () => {
cy.get('[data-test="form"]').within(() => {
cy.get('#test-input').type('spyfu.com')
cy.route('POST', '/sumbit/here').as('postForm') // note that the route needs to match trailing slashes
cy.get('button[type="submit"]').click()
.wait('@postForm')