2021-02-26 15:50:36 +01:00
|
|
|
import 'cypress-plugin-snapshots/commands'
|
|
|
|
|
|
|
|
const patternHandler = {}
|
|
|
|
|
2021-02-09 16:28:01 +01:00
|
|
|
Cypress.Commands.add('interceptLazy', (pattern, handler) => {
|
2021-02-26 15:50:36 +01:00
|
|
|
patternHandler[pattern] = handler
|
2021-02-09 16:28:01 +01:00
|
|
|
return cy.intercept(pattern, (req) => {
|
2021-02-26 15:50:36 +01:00
|
|
|
req.reply(patternHandler[pattern]())
|
2021-02-09 16:28:01 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-02-26 15:50:36 +01:00
|
|
|
Cypress.Commands.add('overrideInterceptLazy', (pattern, handler) => {
|
|
|
|
patternHandler[pattern] = handler
|
|
|
|
})
|
|
|
|
|
2021-02-09 16:28:01 +01:00
|
|
|
Cypress.Commands.add('map', { prevSubject: true }, (subject, method) => {
|
|
|
|
return method(subject)
|
|
|
|
})
|