Skip to content

Commit

Permalink
Merge branch 'develop' into fix-driver-retries
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyrohrbough authored Nov 9, 2021
2 parents e19d176 + e66734d commit 11f5c14
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
27 changes: 27 additions & 0 deletions packages/driver/cypress/integration/commands/xhr_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,33 @@ describe('src/cy/commands/xhr', () => {
})
})

// https://github.com/cypress-io/cypress/issues/18858
it('can stub headers', (done) => {
cy
.route({
url: '/foo',
response: '',
headers: {
'some-header': 'header-value',
},
}).as('getFoo')
.window().then((win) => {
win.$.ajax({
url: '/foo',
error (_a, _b, err) {
done(`Errored but should not have: ${err.stack}`)
},
})

return null
})
.wait('@getFoo')
.then((xhr) => {
expect(xhr.response.headers['some-header']).to.equal('header-value')
done()
})
})

// https://github.com/cypress-io/cypress/issues/2372
it('warns if a percent-encoded URL is used', () => {
cy.spy(Cypress.utils, 'warning')
Expand Down
3 changes: 1 addition & 2 deletions packages/driver/src/cypress/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ export class Server {
this.setHeader(xhr, 'response', route.response, responser)
this.setHeader(xhr, 'matched', `${route.url}`)
this.setHeader(xhr, 'delay', route.delay)

return this.setHeader(xhr, 'headers', route.headers, this.transformHeaders)
this.setHeader(xhr, 'headers', route.headers, this.transformHeaders.bind(this))
}

route (attrs = {}) {
Expand Down

0 comments on commit 11f5c14

Please sign in to comment.