View in #general on Slack
@Vasyl_Malanka: Hi all!
I am trying MockRequest helper and either it doesn’t work or I’m doing something incorrectly:
I.mockRequest('GET', '/customer/account/login', 404);
I.amOnPage('/customer/account/login');
and I see page opening. Shouldn’t I get a 404 page?
@Vasyl_Malanka: ```exports.config = {
helpers: {
Puppeteer: {
url: ‘{url}’,
show: true,
restart: false,
keepBrowserState: true,
keepCookies: true,
fullPageScreenshots: true,
windowSize: ‘1280x1024’,
waitForNavigation: [ ‘domcontentloaded’ ],
waitForAction: 500,
chrome: {
ignoreHTTPSErrors: true,
args: [‘–no-sandbox’, ‘–window-size=1280,1024’],
}
},
MockRequest: {}
},
}```
@davert: @Vasyl_Malanka MockRequest mocks XHR requests in a browser. So mocking is enabled on a page after the page was initially loaded.
So you can’t mock a server (as you intended to). But what you can do is to block some API requests.
Also, MockRequest can be used to mock JS or stylings… But not the full page itself. Again, it blocks network requests inside a page.
So you can block everything you see on Network panel of a browser