Skip to content

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

Closed
ionic-team/ionic-framework
#29666

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

Activity

  1. self-assigned this
    on Oct 17, 2022
  2. rwaskiewicz commented on Oct 17, 2022

    @rwaskiewicz
    Member

    Hey @kraftwer1 👋

    Thanks for the bug report! I can confirm that this behavior does occur in Stencil and agree it's not what I would expect with using beforeAll. This appears to have been done in 66ad23d in order to reduce memory usage. I don't have much more context as to why that behavior is/was configured ATM. I'm going to label this for the team to take a closer look.

    Thanks!

  3. added
    Bug: Validated
    and removed on Oct 17, 2022
  4. removed their assignment
    on Oct 21, 2022
  5. tanner-reits commented on Jun 26, 2024

    @tanner-reits
    Contributor

    A fix for this was included in today's v4.19.0 release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Bug: Validated

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions