-
-
Notifications
You must be signed in to change notification settings - Fork 835
bug: E2E beforeAll() error: The page was already closed #3720
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Stencil Version
2.18.1
Current Behavior
The Jest function beforeAll() cannot be used to set up a page (and possibly even other suite-wide objects) . It seems to end after the first it() and won't work for the second it(), instead it throws the error "The page was already closed".
Example:
describe("suite", () => {
let page
beforeAll(async () => {
page = await newE2EPage()
})
it("1", () => {
const someEl = await page.find('my-component >>> div') // works so far
})
it("2", () => {
const someEl = await page.find('my-component >>> div') // error "The page was already closed"
})
})
It works fine when using beforeEach() instead of beforeAll(), however beforeEach() slows down tests a lot because newE2EPage() takes a lot of time and isn't required in many cases.
Expected Behavior
beforeAll() works just like beforeEach(). According to the Jest docs, beforeAll() and its counterpart afterAll() are built for exactly that: https://jestjs.io/docs/setup-teardown
Steps to Reproduce
Clone the stencil-component-starter repo and alter my-component.e2e.ts as described above.
Code Reproduction URL
https://github.com/ionic-team/stencil-component-starter
Additional Information
No response