forked from cypress-io/cypress-example-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping-spec.cy.js
More file actions
21 lines (20 loc) · 703 Bytes
/
Copy pathping-spec.cy.js
File metadata and controls
21 lines (20 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/// <reference types="Cypress" />
// <a ping="..."> syntax is behind a flag in Firefox
// https://caniuse.com/?search=anchor%20ping
// Thus make sure to enable it in the `setupNodeEvents` function in the
// Cypress configuration via the browser launch options
describe('intercept', () => {
it('stubs anchor ping', () => {
cy.visit('/')
cy.intercept({
method: 'POST',
pathname: '/track',
}, {}).as('ping')
cy.get('a[ping]').click()
cy.location('pathname').should('equal', '/page2.html')
cy.wait('@ping').its('request.headers').should('deep.include', {
'ping-from': 'http://localhost:7080/',
'ping-to': 'http://localhost:7080/page2.html',
})
})
})