Skip to content

bug: E2E beforeAll() error: The page was already closed #3720

@kraftwer1

Description

@kraftwer1

Prerequisites

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

Metadata

Metadata

Labels

Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions