Когда я пытаюсь запустить cy.server (), чтобы смоделировать http-запросы, которые выполняются как часть тестов, я получаю следующую ошибку:
Uncaught CypressError: Cannot call "cy.server()" outside a running test.....
Я не знаю, как заставить это работать. Это мой код:
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)
})