diff --git a/exercises/01.setup/01.problem.vscode-extension/package.json b/exercises/01.setup/01.problem.vscode-extension/package.json index 840bae0..ea5e6e3 100644 --- a/exercises/01.setup/01.problem.vscode-extension/package.json +++ b/exercises/01.setup/01.problem.vscode-extension/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/01.setup/01.solution.vscode-extension/package.json b/exercises/01.setup/01.solution.vscode-extension/package.json index 9dbe683..c1c39f8 100644 --- a/exercises/01.setup/01.solution.vscode-extension/package.json +++ b/exercises/01.setup/01.solution.vscode-extension/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/01.setup/02.problem.multiple-workspaces/package.json b/exercises/01.setup/02.problem.multiple-workspaces/package.json index e53cf39..c007bbb 100644 --- a/exercises/01.setup/02.problem.multiple-workspaces/package.json +++ b/exercises/01.setup/02.problem.multiple-workspaces/package.json @@ -6,6 +6,6 @@ }, "devDependencies": { "@edge-runtime/types": "^4.0.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/01.setup/02.solution.multiple-workspaces/package.json b/exercises/01.setup/02.solution.multiple-workspaces/package.json index aac1a8a..81658f7 100644 --- a/exercises/01.setup/02.solution.multiple-workspaces/package.json +++ b/exercises/01.setup/02.solution.multiple-workspaces/package.json @@ -10,6 +10,6 @@ "@edge-runtime/types": "^4.0.0", "@edge-runtime/vm": "^5.0.0", "edge-runtime": "^4.0.1", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/01.setup/03.problem.code-coverage/package.json b/exercises/01.setup/03.problem.code-coverage/package.json index 71fca90..53654e7 100644 --- a/exercises/01.setup/03.problem.code-coverage/package.json +++ b/exercises/01.setup/03.problem.code-coverage/package.json @@ -6,6 +6,6 @@ }, "devDependencies": { "@vitest/ui": "^3.1.1", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/01.setup/03.solution.code-coverage/package.json b/exercises/01.setup/03.solution.code-coverage/package.json index 71f75e9..039ff65 100644 --- a/exercises/01.setup/03.solution.code-coverage/package.json +++ b/exercises/01.setup/03.solution.code-coverage/package.json @@ -7,6 +7,6 @@ "devDependencies": { "@vitest/coverage-v8": "^3.1.1", "@vitest/ui": "^3.1.1", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/02.context/01.problem.custom-fixtures/package.json b/exercises/02.context/01.problem.custom-fixtures/package.json index f0da948..3f0eabc 100644 --- a/exercises/02.context/01.problem.custom-fixtures/package.json +++ b/exercises/02.context/01.problem.custom-fixtures/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/02.context/01.solution.custom-fixtures/package.json b/exercises/02.context/01.solution.custom-fixtures/package.json index 6e8552a..571e72d 100644 --- a/exercises/02.context/01.solution.custom-fixtures/package.json +++ b/exercises/02.context/01.solution.custom-fixtures/package.json @@ -6,6 +6,6 @@ }, "devDependencies": { "@faker-js/faker": "^9.7.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/02.context/02.problem.automatic-fixtures/package.json b/exercises/02.context/02.problem.automatic-fixtures/package.json index 0ff504a..c795ae6 100644 --- a/exercises/02.context/02.problem.automatic-fixtures/package.json +++ b/exercises/02.context/02.problem.automatic-fixtures/package.json @@ -5,7 +5,7 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" }, "dependencies": { "sqlite3": "^5.1.7" diff --git a/exercises/02.context/02.solution.automatic-fixtures/package.json b/exercises/02.context/02.solution.automatic-fixtures/package.json index 6b50cad..1508611 100644 --- a/exercises/02.context/02.solution.automatic-fixtures/package.json +++ b/exercises/02.context/02.solution.automatic-fixtures/package.json @@ -5,7 +5,7 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" }, "dependencies": { "sqlite3": "^5.1.7" diff --git a/exercises/03.assertions/01.problem.custom-matchers/vitest.setup.ts b/exercises/03.assertions/01.problem.custom-matchers/vitest.setup.ts index a2d703a..7dfde9a 100644 --- a/exercises/03.assertions/01.problem.custom-matchers/vitest.setup.ts +++ b/exercises/03.assertions/01.problem.custom-matchers/vitest.setup.ts @@ -17,17 +17,11 @@ // 🐨 Augment the type definition for the `vitest` module. // 💰 declare module 'name' {} // -// 🐨 Inside the module declaration, declare an interface called `Assertion`. +// 🐨 Inside the module declaration, declare an interface called `Matchers`. // Make it extend the `CustomMatchers` interface you created earlier. // This will extend the type definitions of the `expect()` function to recognize // your custom matchers. -// 💰 interface Assertion extends CustomMatchers {} -// -// 🐨 In a similar way, declare another interface called `MatchersDeclaration` -// and make it extend your `CustomMatchers` interface. -// This will extend the type definitions of the `expect.extend()` function -// to make the implementation of your custom matchers type-safe. -// 💰 interface MatchersDeclaration extends CustomMatchers {} +// 💰 interface Matchers extends CustomMatchers {} // // This covers your custom matcher on the type-level. // Now, let's continue with its implementation! diff --git a/exercises/03.assertions/01.solution.custom-matchers/README.mdx b/exercises/03.assertions/01.solution.custom-matchers/README.mdx index 2562262..9fac454 100644 --- a/exercises/03.assertions/01.solution.custom-matchers/README.mdx +++ b/exercises/03.assertions/01.solution.custom-matchers/README.mdx @@ -50,7 +50,7 @@ But this is only half of the story. Running this `expect()` statement will throw To provide a matcher implementation, call `expect.extend()` and provide it with an object that contains the definitions for your custom matchers: -```ts filename=vitest.setup.ts add=1,13-15 +```ts filename=vitest.setup.ts add=1,12-14 import { expect } from 'vitest' import type { Schema } from 'zod' @@ -59,8 +59,7 @@ interface CustomMatchers { } declare module 'vitest' { - interface Assertion extends CustomMatchers {} - interface MatchersDeclaration extends CustomMatchers {} + interface Matchers extends CustomMatchers {} } expect.extend({ diff --git a/exercises/03.assertions/02.problem.asymmetric-matchers/package.json b/exercises/03.assertions/02.problem.asymmetric-matchers/package.json index ff50e60..af107e0 100644 --- a/exercises/03.assertions/02.problem.asymmetric-matchers/package.json +++ b/exercises/03.assertions/02.problem.asymmetric-matchers/package.json @@ -6,7 +6,7 @@ }, "devDependencies": { "@types/node": "^24.3.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" }, "dependencies": { "zod": "^3.24.2" diff --git a/exercises/03.assertions/02.solution.asymmetric-matchers/README.mdx b/exercises/03.assertions/02.solution.asymmetric-matchers/README.mdx index 0032e3b..976d1f8 100644 --- a/exercises/03.assertions/02.solution.asymmetric-matchers/README.mdx +++ b/exercises/03.assertions/02.solution.asymmetric-matchers/README.mdx @@ -2,19 +2,9 @@ -To expose my `.toMatchSchema()` matcher as an asymmetric matcher, I will extend the `AsymmetricMatchersContaining` interface of the `vitest` module: - -```ts nonumber add=4 -declare module 'vitest' { - interface Assertion extends CustomMatchers {} - interface MatchersDeclaration extends CustomMatchers {} - interface AsymmetricMatchersContaining extends CustomMatchers {} -} -``` - -> The `AsymmetricMatchersContaining` controls the matcher types available as asymmetric matchers on the `expect` object (e.g. `expect.objectContaining()`). +To expose my `.toMatchSchema()` matcher as an asymmetric matcher, I need to... do nothing! Vitest automatically provides both symmetric and asymmetric versions for your custom matchers, including type definitions. -With this change, the type error in the `src/fetch-user.test.ts` is finally gone! 🎉 +All that's left for me to do is to use the asymmetric version of the `toMatchSchema()` matcher in tests: ```ts filename=src/fetch-user.test.ts highlight=6 import { fetchUser } from './fetch-user' @@ -26,9 +16,7 @@ test('returns the user by id', async () => { }) ``` -This means that I can use the `.toMatchSchema()` matcher as asymmetric, which is exactly what I need to complete the test case for user transactions. - -In `src/fetch-transaction.test.ts`, I will write the remaining test: +And in `src/fetch-transaction.test.ts`, I will write the remaining test: ```ts filename=src/fetch-transaction.test.ts add=5-11 import { fetchTransaction, type Transaction } from './fetch-transaction' @@ -45,7 +33,7 @@ test('fetches a transaction between two users', async () => { }) ``` -> 🦉 Notice how I'm using schema validation to make sure that transaction's `issuer` and `recipient` properties both match the `userSchema`. +> 🦉 Notice the usage of the `Transaction` type as the type argument to the default `.toEqual` matcher. It ensures that the expected value I pass to that matcher is type-safe. ## Related materials diff --git a/exercises/03.assertions/02.solution.asymmetric-matchers/package.json b/exercises/03.assertions/02.solution.asymmetric-matchers/package.json index baef39b..9236234 100644 --- a/exercises/03.assertions/02.solution.asymmetric-matchers/package.json +++ b/exercises/03.assertions/02.solution.asymmetric-matchers/package.json @@ -6,7 +6,7 @@ }, "devDependencies": { "@types/node": "^24.3.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" }, "dependencies": { "zod": "^3.24.2" diff --git a/exercises/03.assertions/03.problem.custom-quality-testers/package.json b/exercises/03.assertions/03.problem.custom-quality-testers/package.json index e21beab..e7fc938 100644 --- a/exercises/03.assertions/03.problem.custom-quality-testers/package.json +++ b/exercises/03.assertions/03.problem.custom-quality-testers/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/03.assertions/03.solution.custom-equality-testers/package.json b/exercises/03.assertions/03.solution.custom-equality-testers/package.json index f899eec..6914ae0 100644 --- a/exercises/03.assertions/03.solution.custom-equality-testers/package.json +++ b/exercises/03.assertions/03.solution.custom-equality-testers/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/03.assertions/04.problem.retryable-assertions/package.json b/exercises/03.assertions/04.problem.retryable-assertions/package.json index ee3dcd9..6e26beb 100644 --- a/exercises/03.assertions/04.problem.retryable-assertions/package.json +++ b/exercises/03.assertions/04.problem.retryable-assertions/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/03.assertions/04.solution.retryable-assertions/package.json b/exercises/03.assertions/04.solution.retryable-assertions/package.json index ed2d717..89cea5b 100644 --- a/exercises/03.assertions/04.solution.retryable-assertions/package.json +++ b/exercises/03.assertions/04.solution.retryable-assertions/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/03.assertions/05.problem.soft-assertions/package.json b/exercises/03.assertions/05.problem.soft-assertions/package.json index ddba47f..abd9c0c 100644 --- a/exercises/03.assertions/05.problem.soft-assertions/package.json +++ b/exercises/03.assertions/05.problem.soft-assertions/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/03.assertions/05.solution.soft-assertions/package.json b/exercises/03.assertions/05.solution.soft-assertions/package.json index 1fc02b2..743cd5c 100644 --- a/exercises/03.assertions/05.solution.soft-assertions/package.json +++ b/exercises/03.assertions/05.solution.soft-assertions/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/04.performance/01.problem.profiling-slow-tests/package.json b/exercises/04.performance/01.problem.profiling-slow-tests/package.json index 23885e7..4f48c52 100644 --- a/exercises/04.performance/01.problem.profiling-slow-tests/package.json +++ b/exercises/04.performance/01.problem.profiling-slow-tests/package.json @@ -5,7 +5,7 @@ "test": "vitest --no-cache" }, "devDependencies": { - "vitest": "^3.1.1", + "vitest": "^3.2.4", "vitest-profiler": "^0.1.8" } } diff --git a/exercises/04.performance/01.solution.profiling-slow-tests/package.json b/exercises/04.performance/01.solution.profiling-slow-tests/package.json index 890582d..da2e402 100644 --- a/exercises/04.performance/01.solution.profiling-slow-tests/package.json +++ b/exercises/04.performance/01.solution.profiling-slow-tests/package.json @@ -6,7 +6,7 @@ "test:profile": "vitest-profiler npm test" }, "devDependencies": { - "vitest": "^3.1.1", + "vitest": "^3.2.4", "vitest-profiler": "^0.1.8" } } diff --git a/exercises/04.performance/02.problem.concurrency/package.json b/exercises/04.performance/02.problem.concurrency/package.json index 8ebada4..27a6a93 100644 --- a/exercises/04.performance/02.problem.concurrency/package.json +++ b/exercises/04.performance/02.problem.concurrency/package.json @@ -6,6 +6,6 @@ }, "devDependencies": { "@types/node": "^24.3.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/04.performance/02.solution.concurrency/package.json b/exercises/04.performance/02.solution.concurrency/package.json index ade23a8..c35d757 100644 --- a/exercises/04.performance/02.solution.concurrency/package.json +++ b/exercises/04.performance/02.solution.concurrency/package.json @@ -6,6 +6,6 @@ }, "devDependencies": { "@types/node": "^24.3.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/04.performance/03.problem.test-isolation/package.json b/exercises/04.performance/03.problem.test-isolation/package.json index 7dc4083..1751a6f 100644 --- a/exercises/04.performance/03.problem.test-isolation/package.json +++ b/exercises/04.performance/03.problem.test-isolation/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/exercises/04.performance/03.solution.test-isolation/package.json b/exercises/04.performance/03.solution.test-isolation/package.json index b5abeb1..951f3ed 100644 --- a/exercises/04.performance/03.solution.test-isolation/package.json +++ b/exercises/04.performance/03.solution.test-isolation/package.json @@ -5,6 +5,6 @@ "test": "vitest" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } } diff --git a/package-lock.json b/package-lock.json index 38e9e60..93c65cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,20 +25,20 @@ "exercises/01.setup/01.problem.vscode-extension": { "name": "exercises_01.setup_01.problem.vscode-extension", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/01.setup/01.solution.vscode-extension": { "name": "exercises_01.setup_01.solution.vscode-extension", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/01.setup/02.problem.multiple-workspaces": { "name": "exercises_01.setup_02.problem.multiple-workspaces", "devDependencies": { "@edge-runtime/types": "^4.0.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/01.setup/02.solution.multiple-workspaces": { @@ -47,14 +47,14 @@ "@edge-runtime/types": "^4.0.0", "@edge-runtime/vm": "^5.0.0", "edge-runtime": "^4.0.1", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/01.setup/03.problem.code-coverage": { "name": "exercises_01.setup_03.problem.code-coverage", "devDependencies": { "@vitest/ui": "^3.1.1", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/01.setup/03.solution.code-coverage": { @@ -62,20 +62,20 @@ "devDependencies": { "@vitest/coverage-v8": "^3.1.1", "@vitest/ui": "^3.1.1", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/02.context/01.problem.custom-fixtures": { "name": "exercises_02.context_01.problem.custom-fixtures", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/02.context/01.solution.custom-fixtures": { "name": "exercises_02.context_01.solution.custom-fixtures", "devDependencies": { "@faker-js/faker": "^9.7.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/02.context/02.problem.automatic-fixtures": { @@ -84,7 +84,7 @@ "sqlite3": "^5.1.7" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/02.context/02.solution.automatic-fixtures": { @@ -93,7 +93,7 @@ "sqlite3": "^5.1.7" }, "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/03.assertions/01.problem.custom-matchers": { @@ -123,7 +123,7 @@ }, "devDependencies": { "@types/node": "^24.3.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/03.assertions/02.solution.asymmetric-matchers": { @@ -133,56 +133,56 @@ }, "devDependencies": { "@types/node": "^24.3.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/03.assertions/03.problem.custom-quality-testers": { "name": "exercises_03.assertions_03.problem.custom-quality-testers", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/03.assertions/03.solution.custom-equality-testers": { "name": "exercises_03.assertions_03.solution.custom-equality-testers", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/03.assertions/04.problem.retryable-assertions": { "name": "exercises_03.assertions_04.problem.retryable-assertions", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/03.assertions/04.solution.retryable-assertions": { "name": "exercises_03.assertions_04.solution.retryable-assertions", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/03.assertions/05.problem.soft-assertions": { "name": "exercises_03.assertions_05.problem.soft-assertions", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/03.assertions/05.solution.soft-assertions": { "name": "exercises_03.assertions_05.solution.soft-assertions", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/04.performance/01.problem.profiling-slow-tests": { "name": "exercises_04.performance_01.problem.profiling-slow-tests", "devDependencies": { - "vitest": "^3.1.1", + "vitest": "^3.2.4", "vitest-profiler": "^0.1.8" } }, "exercises/04.performance/01.solution.profiling-slow-tests": { "name": "exercises_04.performance_01.solution.profiling-slow-tests", "devDependencies": { - "vitest": "^3.1.1", + "vitest": "^3.2.4", "vitest-profiler": "^0.1.8" } }, @@ -190,26 +190,26 @@ "name": "exercises_04.performance_02.problem.concurrency", "devDependencies": { "@types/node": "^24.3.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/04.performance/02.solution.concurrency": { "name": "exercises_04.performance_02.solution.concurrency", "devDependencies": { "@types/node": "^24.3.0", - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/04.performance/03.problem.test-isolation": { "name": "exercises_04.performance_03.problem.test-isolation", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/04.performance/03.solution.test-isolation": { "name": "exercises_04.performance_03.solution.test-isolation", "devDependencies": { - "vitest": "^3.1.1" + "vitest": "^3.2.4" } }, "exercises/04.performance/04.problem.sharding": {