diff --git a/exercises/04.performance/03.problem.test-isolation/README.mdx b/exercises/04.performance/03.problem.test-isolation/README.mdx index 0eb42fc..df78afc 100644 --- a/exercises/04.performance/03.problem.test-isolation/README.mdx +++ b/exercises/04.performance/03.problem.test-isolation/README.mdx @@ -1,3 +1,14 @@ # Test isolation -... +Vitest runs every test file in a separate worker, which enables parallel execution and speeds up tests by default. + +Each worker has its own isolated environment, meaning that if one test file mutates a global variable, other test files won't be affected by this mutation. This test file-level isolation is a great feature for preventing test interference. + +### The Problem +While test isolation provides benefits, **it comes with a performance cost.** + +When you have hundreds or thousands of test files, the overhead of spawning a worker for each file accumulates and can significantly degrade performance. + +### Your Task + +Follow the instructions to disable test isolation and observe the performance difference it makes in projects with a large number of test files. \ No newline at end of file diff --git a/exercises/04.performance/03.solution.test-isolation/README.mdx b/exercises/04.performance/03.solution.test-isolation/README.mdx index e2141cd..29f2dd1 100644 --- a/exercises/04.performance/03.solution.test-isolation/README.mdx +++ b/exercises/04.performance/03.solution.test-isolation/README.mdx @@ -32,4 +32,24 @@ This also means that you can benefit from correctly written tests in more ways t ## Your task -👨‍💼 ... +Opt out of the default test isolation and observe how this change affects how your tests are ran. + +### Configuration Change + +To disable test isolation and prevent Vitest from spawning a worker for each test file: + +1. Open your `vitest.config.js` (or `vitest.config.ts`) +2. Add or modify the test configuration: + +```javascript +export default defineConfig({ + test: { + globals: true, + isolate: false, + }, +}) +``` + +Then run `npm test`. + +What change did this make to your test run? \ No newline at end of file