【发布时间】:2022-12-28 03:52:56
【问题描述】:
How can I log a "request.body" from cypress interceptor. Here is the code
beforeEach(() => {
cy.log("---- -- Running beforeEach");
cy.intercept("POST", "/graphql", (req) => {
cy.log("-- --- -- loging from interceptor", req.body);
return req;
});
});
I get this error :
Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
If I remove cy.log no errors are raised. So how can I log this? This runs on CI.
Will use https://github.com/flotwig/cypress-log-to-output plugin if no other way.
【问题讨论】:
-
I would try
req.continue()instead ofreturn req-- is there a specific reason you are returning the request? -
either return or req.continue() the issue persists. It is the cy.log within the interceptor that is causing the error.
标签: cypress interceptor cypress-intercept