Currently, each test file (or group of tests) uses beforeAll and afterAll hooks to create and delete a project, respectively. This approach is redundant and negatively impacts test performance.
The objective is to refactor the test setup so that the project is created only once at the beginning of the tests and deleted after all tests finish (regardless of success or failure).
Checklist:
-
Remove tests.setupFiles
- Open the
vitest.config.mts file.
- Remove the
tests.setupFiles property.
-
Add tests.globalSetup
- In
vitest.config.mts, add a tests.globalSetup property pointing to a configuration file.
- Ensure the file runs only for integration tests by checking
process.env.TEST_ENV === 'integration'.
- Update
package.json -> scripts -> test:integration to set this flag.
-
Create a Global Setup File
-
Clean Up Test Files
- Remove
beforeAll and afterAll hooks from test files where they are no longer needed.
Notes:
Submit a pull request to the release/v5.0.0 branch.
Currently, each test file (or group of tests) uses
beforeAllandafterAllhooks to create and delete a project, respectively. This approach is redundant and negatively impacts test performance.The objective is to refactor the test setup so that the project is created only once at the beginning of the tests and deleted after all tests finish (regardless of success or failure).
Checklist:
Remove
tests.setupFilesvitest.config.mtsfile.tests.setupFilesproperty.Add
tests.globalSetupvitest.config.mts, add atests.globalSetupproperty pointing to a configuration file.process.env.TEST_ENV === 'integration'.package.json -> scripts -> test:integrationto set this flag.Create a Global Setup File
Use the following template for the configuration file:
Clean Up Test Files
beforeAllandafterAllhooks from test files where they are no longer needed.Notes:
Submit a pull request to the
release/v5.0.0branch.