Skip to content

Unexpected behaviour of beforeEach outside of suite without test isolation #61854

@NiedziolkaMichal

Description

@NiedziolkaMichal

What is the problem this feature will solve?

In test runners such as jest or vitest, callbacks passed to the methods before, after, beforeEach or afterEach not wrapped in any describe, are called only when tests in their module are about to start or end. That's also the current behaviour when --test-isolation=process. Unfortunately, when the --test-isolation is none, the callbacks we pass to those 4 functions are added as global callbacks and they start to be called before/after each test in any file.

That's unexpected behaviour and it makes it more difficult to migrate from other test runners to node test runner or from the default --test-isolation=process.

What is the feature you are proposing to solve the problem?

Each module should be wrapped in a suite by default, so the callbacks don't leak to the other test modules. The only exception should be callbacks that we pass to those 4 methods in the global setup file(or its imports I guess).

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions