Skip to content

Instantly share code, notes, and snippets.

@bobmacneal
Created December 23, 2019 15:12
Show Gist options
  • Save bobmacneal/e60ac2ef7b804bed7a99f9de639c7bc5 to your computer and use it in GitHub Desktop.
Save bobmacneal/e60ac2ef7b804bed7a99f9de639c7bc5 to your computer and use it in GitHub Desktop.
Cypress Command to Stub /sockjs-node/info?t=*
Cypress.Commands.add('mockSockJs', () => {
const url = '/sockjs-node/info?t=*'
cy.server()
cy.route({
method: 'GET',
url: url,
response: 'fixture:sockJs.json',
})
})
@bobmacneal
Copy link
Author

bobmacneal commented Dec 23, 2019

In the interest of stubbing all network traffic in my Cypress tests, I've created this Stub for /sockjs-node/info?t=* using an asterisk for the query parameter t.

Screen Shot 2019-12-23 at 9 13 18 AM

The cypress/fixture file, sockJs.json, contains the following data:

Screen Shot 2019-12-23 at 9 23 37 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment