When I try to run cy.server() in order to mock http requests that are executed as part of the tests, I get the following error:
Uncaught CypressError: Cannot call "cy.server()" outside a running test.....
I don't know how to get this to work. This is my code:
import { Given, Then } from 'cypress-cucumber-preprocessor/steps'
beforeEach(() => {
cy.server()
cy.route({
method: 'GET',
url: '/',
response: []
})
})
const url = 'http://localhost:8080'
Given('I click the big button', () => {
cy.visit(url)
cy.get('.btn').click()
})
Then('I can get the MOTD', (title) => {
cy.title().should('include', title)
})
Aucun commentaire:
Enregistrer un commentaire