-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal : fix for intercepting HTTP calls during page load #185
Comments
Afaik this package was build before WebdriverIO had native mocking capabilities and continues to stay a great alternative for browser tests where Puppeteer and CDP can't be used. Not sure how much it makes sense to use both together, because e.g.: browser.expectRequest('GET', /\/api\/foo/, 200); is the same as: await expect(mock).toBeRequestedWith({
url: '*/api/foo',
method: 'GET', // [optional] string | array
statusCode: 200
}) If this package has some useful functionality that native WebdriverIO APIs don't have I suggest we port them over. What do you think? |
The thing is, I was never able to make Even this simple example doesn't work: const url = 'http://localhost:4200';
const mock = browser.mock(url);
await browser.url(url);
await expect(mock).toBeRequestedWith({ url }); Am I doing something wrong ? |
Not sure, is it giving you an error message? Are you using latest WebdriverIO? |
wdio version: v7.16.10 spec describe('Test', () => {
it('test', async () => {
const url = 'http://localhost:4200';
const mock = browser.mock(url);
await browser.url(url);
await expect(mock).toBeRequestedWith({ url });
});
}); result [chrome 96.0.4664.55 mac os x #0-0] Expect mock to be called with
Expected: {"url": "http://localhost:4200"}
Received: "was not called" |
While trying to intercept http requests originating from an Angular application, I came accross the following restriction mentionned in the README:
Though, I managed to fix it that way:
The idea behind it, is to inject a script in the
index.html
root file of the Angular application that will set up the interceptor service before the app is actually started.I let you guys decide whether this could be added directly to the library or wrote somewhere in the documentation 😉
The text was updated successfully, but these errors were encountered: