Request is already handled!
describe('Test', () => {
beforeEach(async () => {
jest.setTimeout = 30000;
await page.setRequestInterception(true);
page.on('request', request => {
request.continue();
})
await page.goto('https://www.google.com/');
});
afterEach(async () => {
page.removeListener("request", () => {});
})
it('case1:...', async () => {
await expect(page).toMatch('Google');
})
it('case2:...', async () => {
await expect(page).toMatch('Google');
})
});
I want to modify some response data in every testcase, so help me plz.
ah...I've got it fixed by doing this:
beforeEach(async () => {
jest.setTimeout = 30000;
page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', request => {
request.continue();
})
await page.goto('https://www.google.com/');
});
Is this the actual solution though? Why do we need to create a new page, when each test run should start a new page all the time?
@neoziro
If this was the only alternative, how can we add this to our global setup and teardowns so we don't have to do it for each test that we need it to?
Looks like this issue should be reopened, it's a really weird behaviour.
Maybe @gregberge can re-open this issue? Or @songguohfut
I instead reposted https://github.com/smooth-code/jest-puppeteer/issues/308
Most helpful comment
Looks like this issue should be reopened, it's a really weird behaviour.