Repository navigation
FE-1862: Upgrade to Vitest 5 #9945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a40b4d3
ea0a3f2
73d4384
c61c56c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,73 @@ | ||
| diff --git a/dist/cjs/internal/internal.js b/dist/cjs/internal/internal.js | ||
| index dee6eec6cd0646708773eb9e89d4e835858b3f5c..b9ce97e9b481980ff5a9092bf09c8d3179fed495 100644 | ||
| index dee6eec..14424ac 100644 | ||
| --- a/dist/cjs/internal/internal.js | ||
| +++ b/dist/cjs/internal/internal.js | ||
| @@ -28,7 +28,9 @@ const defaultApi = /*#__PURE__*/Object.assign(V.it, { | ||
| @@ -28,7 +28,11 @@ const defaultApi = /*#__PURE__*/Object.assign(V.it, { | ||
| }); | ||
| const runPromise = ctx => effect => Effect.gen(function* () { | ||
| const exitFiber = yield* Effect.fork(Effect.exit(effect)); | ||
| - ctx?.onTestFinished(() => Fiber.interrupt(exitFiber).pipe(Effect.asVoid, Effect.runPromise)); | ||
| + // Vitest 4 moved onTestFinished off the test context. Keep Effect 3's | ||
| + // stable @effect/vitest usable until https://github.com/Effect-TS/effect/pull/5980 is released. | ||
| + V.onTestFinished(() => Fiber.interrupt(exitFiber).pipe(Effect.asVoid, Effect.runPromise)); | ||
| + // Register on the test's own context, which concurrent tests do not share. | ||
| + // Vitest 4.0 contexts had no onTestFinished, so use the global hook there. | ||
| + if (ctx) { | ||
| + (ctx.onTestFinished ?? V.onTestFinished)(() => Fiber.interrupt(exitFiber).pipe(Effect.asVoid, Effect.runPromise)); | ||
| + } | ||
| const exit = yield* Fiber.join(exitFiber); | ||
| if (Exit.isSuccess(exit)) { | ||
| return () => exit.value; | ||
| diff --git a/dist/esm/internal/internal.js b/dist/esm/internal/internal.js | ||
| index adb6b213294cbbc1559f7a283b4a84df41d8342e..a04cef4d46c499aac08518abf0a99759ce800039 100644 | ||
| index adb6b21..379aee7 100644 | ||
| --- a/dist/esm/internal/internal.js | ||
| +++ b/dist/esm/internal/internal.js | ||
| @@ -21,7 +21,9 @@ const defaultApi = /*#__PURE__*/Object.assign(V.it, { | ||
| @@ -21,7 +21,11 @@ const defaultApi = /*#__PURE__*/Object.assign(V.it, { | ||
| }); | ||
| const runPromise = ctx => effect => Effect.gen(function* () { | ||
| const exitFiber = yield* Effect.fork(Effect.exit(effect)); | ||
| - ctx?.onTestFinished(() => Fiber.interrupt(exitFiber).pipe(Effect.asVoid, Effect.runPromise)); | ||
| + // Vitest 4 moved onTestFinished off the test context. Keep Effect 3's | ||
| + // stable @effect/vitest usable until https://github.com/Effect-TS/effect/pull/5980 is released. | ||
| + V.onTestFinished(() => Fiber.interrupt(exitFiber).pipe(Effect.asVoid, Effect.runPromise)); | ||
| + // Register on the test's own context, which concurrent tests do not share. | ||
| + // Vitest 4.0 contexts had no onTestFinished, so use the global hook there. | ||
| + if (ctx) { | ||
| + (ctx.onTestFinished ?? V.onTestFinished)(() => Fiber.interrupt(exitFiber).pipe(Effect.asVoid, Effect.runPromise)); | ||
| + } | ||
| const exit = yield* Fiber.join(exitFiber); | ||
| if (Exit.isSuccess(exit)) { | ||
| return () => exit.value; | ||
| diff --git a/package.json b/package.json | ||
| index 1ceac68f8e5cfed5d014c4066414c4f8eec67a69..3c5cac8abdae6087e927fab2669b736c4a0be5c4 100644 | ||
| index 1ceac68..ac43401 100644 | ||
| --- a/package.json | ||
| +++ b/package.json | ||
| @@ -11,7 +11,7 @@ | ||
| "sideEffects": [], | ||
| "homepage": "https://effect.website", | ||
| "peerDependencies": { | ||
| - "vitest": "^3.2.0", | ||
| + "vitest": "^3.2.0 || ^4.0.0", | ||
| + "vitest": "^3.2.0 || ^4.0.0 || ^5.0.0", | ||
| "effect": "^3.21.0" | ||
| }, | ||
| "publishConfig": { | ||
| diff --git a/src/internal/internal.ts b/src/internal/internal.ts | ||
| index bd11019b8ad51bd49cc3015f8c69aac04ad18822..1d8a04e1ae3d195d75553fb3944efdd9720f64ca 100644 | ||
| index bd11019..9313f73 100644 | ||
| --- a/src/internal/internal.ts | ||
| +++ b/src/internal/internal.ts | ||
| @@ -29,7 +29,9 @@ const runPromise = (ctx?: Vitest.TestContext) => <E, A>(effect: Effect.Effect<A, | ||
| @@ -29,12 +29,16 @@ const runPromise = (ctx?: Vitest.TestContext) => <E, A>(effect: Effect.Effect<A, | ||
| Effect.gen(function*() { | ||
| const exitFiber = yield* Effect.fork(Effect.exit(effect)) | ||
|
|
||
| - ctx?.onTestFinished(() => | ||
| + // Vitest 4 moved onTestFinished off the test context. Keep Effect 3's | ||
| + // stable @effect/vitest usable until https://github.com/Effect-TS/effect/pull/5980 is released. | ||
| + V.onTestFinished(() => | ||
| Fiber.interrupt(exitFiber).pipe( | ||
| Effect.asVoid, | ||
| Effect.runPromise | ||
| - Fiber.interrupt(exitFiber).pipe( | ||
| - Effect.asVoid, | ||
| - Effect.runPromise | ||
| + // Register on the test's own context, which concurrent tests do not share. | ||
| + // Vitest 4.0 contexts had no onTestFinished, so use the global hook there. | ||
| + if (ctx) { | ||
| + ;(ctx.onTestFinished ?? V.onTestFinished)(() => | ||
| + Fiber.interrupt(exitFiber).pipe( | ||
| + Effect.asVoid, | ||
| + Effect.runPromise | ||
| + ) | ||
| ) | ||
| - ) | ||
| + } | ||
|
|
||
| const exit = yield* Fiber.join(exitFiber) | ||
| if (Exit.isSuccess(exit)) { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,6 +193,7 @@ | |
| "rimraf": "6.1.3", | ||
| "sass": "1.93.2", | ||
| "typescript": "catalog:", | ||
| "vite": "catalog:", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is vite being added as a dependency - I don't think hash-frontend uses vite? (or is it a peer dep for vitest 5)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a peer dependency, vitest requires it, but it's no longer installed since vitest 5, so we need to install it ourselves. |
||
| "vitest": "catalog:", | ||
| "wait-on": "9.0.1", | ||
| "webpack": "5.107.2" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| "oxlint": "1.86.0", | ||
| "tsx": "catalog:", | ||
| "typescript": "catalog:", | ||
| "vite": "catalog:", | ||
| "vitest": "catalog:" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ | |
| "oxfmt": "0.71.0", | ||
| "rimraf": "6.1.3", | ||
| "typescript": "catalog:", | ||
| "vite": "catalog:", | ||
| "vitest": "catalog:" | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.