如何在cypress中拦截GetById?

时间:2021-04-08 04:52:36

标签: angular typescript cypress

我目前正在 cypress 中拦截 Get api 并且它工作正常:

cy.intercept('GET','/api/products', {
    body: list,
});

现在我希望能够拦截 GetById - 我尝试了以下但它不起作用,它仍然认为上面的代码是一个 get all:

cy.intercept('GET','/api/products/1234', {
    body: list,
});

cypress 有没有办法拦截带参数的url?

1 个答案:

答案 0 :(得分:0)

为了解决这个问题,我不得不更新到 cypress 7.0.1。最新版本的cypress,对url的检查更加严格。