Skip to content

[BUG] afterAll\afterEach hook runs for skipped test #19984

@denkorz

Description

@denkorz

Context:

  • Playwright Version: 1.29.1
  • Browser: Chromium

System:

  • OS: Windows 10 10.0.19044
  • Memory: 16.72 GB / 31.75 GB

Binaries:

  • Node: 19.0.1 - C:\Program Files\nodejs\node.EXE
  • npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD

Code Snippet

My test depends on the environment and some users have to be added manually or we should test them only when they are available. So I added this skip call according to how it's described in the documentation: https://playwright.dev/docs/api/class-test#test-describe-skip

test.beforeAll(async ({ browser }) => {
   userModel = await usersApiClient.getUserByName(userName);
  test.skip(userModel === null, `User for this test (${userName}) is not available`);
}

If I use this approach:

  • next steps of beforeAll hook are skipped - good.
  • test is skipped - good
  • afterAll\afterEach hook is running and fails because userModel is null and it tries to clean up the user.
    So even if test is skipped from beforeAll hook, I have also to add condition to afterAll hook

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions