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.
Current fix is...
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/');
});
However we'd like to avoid having to do await browser.newPage() every time.
I've managed to get around this by using resetPage:
beforeEach(async () => {
await jestPuppeteer.resetPage();
await page.goto('http://localhost:5001');
});
I don't know if it makes a difference with your case but i'm using the jest command line option --runInBand.
@counterbeing I'll try and use this and report back.
Most helpful comment
I've managed to get around this by using
resetPage:I don't know if it makes a difference with your case but i'm using the jest command line option
--runInBand.