I have an issue with cy.intercept that I can't seem to figure out how to solve, in our project we used to use route, but now trying to start using intercept. So, our rotes used to be defined like this:
'upload: {route: `api/cases/import-data/**`, alias:'upload'}
So we used minimatch's **
to mach anything after the import-data/
, and that is currently not working with intercept.
So I'm trying to use RegExp instead now, so my question is pretty simple, what should I replace **
with in a RegExp? Nothing seems to be working and I'm getting a timeout error.
My function:
function listener({ route, method = 'POST', onRes = () => { }, alias = 'listener' }) {
const url = new RegExp(`${Cypress.config().beUrl}${route}`);
cy.intercept(
method,
url,
(req) => {
req.reply(res => {
onRes(res);
});
}
).as(alias);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…