-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
Description
What is the problem this feature will solve?
It's common to apply some logic before or after each test or a test suite. For example to add a property to the global, to always mock a certain module or to always restore mocks after each test.
When --test-global-setup is used along with --test-isolation=none, this feature works quite nicely. We can add before, beforeEach, after and afterEach in the global setup and the callbacks will be correctly called. The only thing that I found to be unexpected, is that the before callback passed in the global setup gets called before globalSetup function.
When --test-isolation is process, which is the default, things start to get weird. First the before in the global setup module gets called, then globalSetup function, then beforeEach in the global setup. Now all the tests run in separate processes, so whatever we assign in the global setup doesn't affect them. When the tests finish, callbacks in the global setup are run in the following order: afterEach, globalTeardown, after.
What is the feature you are proposing to solve the problem?
I would propose:
- callback passed to the
beforefunction should be called after theglobalSetup - global setup module should be loaded in each test sub process
- Callbacks passed to the
before,beforeEach,afterEach&afterin the global setup module should be called in each test subprocess. MethodsglobalSetupandglobalTeardownshould not be called in each subprocess (current behaviour).
What alternatives have you considered?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status