Current behavior:
I'm getting error in Cypress app console: CypressError: cy.route() cannot be invoked before starting the cy.server() when I use cy.server() in top before hook and then cy.route() in children contexts before hooks.
If I remove top cy.server() and move it to before hook before each cy.route() call then I get fail for second describe context with error: CypressError: The XHR server is unavailable or missing. This should never happen and likely is a bug. Open an issue if you see this message.
Desired behavior:
I should be able to use cy.route() and cy.server() within before hooks.
Test code:
describe('test', () => {
before(() => {
cy.server()
})
describe('case with http 500', () => {
before(() => {
// cy.server()
cy.route({
method: 'GET',
url: '/api?*',
status: 500,
response: {}
})
cy.visit('http://app.dev/')
})
it('test n1', () => {
})
it('test nr 2', () => {
})
})
describe('case with http 408', () => {
before(() => {
// cy.server()
cy.route({
method: 'GET',
url: '/api?*',
status: 408,
response: {}
})
cy.visit('http://app.dev')
})
it('test nr 3', () => {
})
it('test nr 4', () => {
})
})
})
Current behavior:
I'm getting error in Cypress app console:
CypressError: cy.route() cannot be invoked before starting the cy.server()when I usecy.server()in topbeforehook and thency.route()in children contextsbeforehooks.If I remove top
cy.server()and move it tobeforehook before eachcy.route()call then I get fail for second describe context with error:CypressError: The XHR server is unavailable or missing. This should never happen and likely is a bug. Open an issue if you see this message.Desired behavior:
I should be able to use
cy.route()andcy.server()withinbeforehooks.Test code: