[v9] How to create network requests spies and mocks with dynamic responses? #13729
-
|
Hello, i am trying to setup some tests with network request mocks and spies, and cannot get it to work how it is written in documentation. Request spyAccording to https://webdriver.io/docs/mocksandspies#spies the Example: it('request spy', async () => {
const mock = await browser.mock('https://the-internet.herokuapp.com/js/foundation/foundation.js', {
method: 'get',
statusCode: 200,
});
// uncomment following for test to pass, but it modifies the response body
// mock.respond({})
await browser.url('https://the-internet.herokuapp.com/');
await mock.waitForResponse();
await expect(mock.calls.length).toBe(1);
});How can I make the mock act like a spy and let it continue with the original response it would normally receive? Edit: I think i found a possible workaround by using e.g. Dynamic responseAccording to https://webdriver.io/docs/mocksandspies#dynamic-responses Are docs not up to date or am i doing something wrong? Thanks for helping |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Thank you for raising this. I've created a PR in #13731 with a fix. |
Beta Was this translation helpful? Give feedback.
Thank you for raising this. I've created a PR in #13731 with a fix.