Hello, I noticed that the state of the browser/page remains between tests (it).
AFAIK the common practice is to have each it independent so running a single it or all of them are guaranteed to give the same result.
I can imagine though that one could want to execute multiple it to cover a single scenario with a describe. So I'm curious to know if the current behaviour is actually intended.
I prefer to let the user decide, you can put a "before" or a "beforeEach" and reset what you need.
Could you show an example of how to reset the page between tests?
Is it sufficient to just do:
beforeEach(async () => {
await page.close();
page = await context.newPage();
});
It looks like different things are setup on page based on settings.
https://github.com/smooth-code/jest-puppeteer/blob/cc9bbfa493349cc88273120996e713523cf86714/packages/jest-environment-puppeteer/src/PuppeteerEnvironment.js#L61-L63
It seems like it would be easier to have a setting in jest-puppeteer.config.js that will reset page with the same configuration between tests.
Or maybe provide a jestPuppeteer.resetPage() function that could easily be called to reset to the same configuration?
@UziTech yes I think it is a good idea, can you open another issue to describe the feature?
Has this feature been created.. I am having the same issues in an angular app
@UziTech
Most helpful comment
Could you show an example of how to reset the page between tests?
Is it sufficient to just do:
It looks like different things are setup on page based on settings.
https://github.com/smooth-code/jest-puppeteer/blob/cc9bbfa493349cc88273120996e713523cf86714/packages/jest-environment-puppeteer/src/PuppeteerEnvironment.js#L61-L63
It seems like it would be easier to have a setting in
jest-puppeteer.config.jsthat will reset page with the same configuration between tests.