-
Notifications
You must be signed in to change notification settings - Fork 496
Chore: Upgrade Vitest to v4 #7797
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
e2c1788
7fcfec9
be374fc
3533103
6124ed8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ catalog: | |
| '@nx/playwright': 22.2.6 | ||
| '@nx/storybook': 22.2.4 | ||
| '@nx/vite': 22.2.6 | ||
| '@pinia/testing': ^0.1.5 | ||
| '@pinia/testing': ^1.0.3 | ||
| '@playwright/test': ^1.57.0 | ||
| '@prettier/plugin-oxc': ^0.1.3 | ||
| '@primeuix/forms': 0.0.2 | ||
|
|
@@ -26,7 +26,7 @@ catalog: | |
| '@primevue/icons': 4.2.5 | ||
| '@primevue/themes': ^4.2.5 | ||
| '@sentry/vite-plugin': ^4.6.0 | ||
| '@sentry/vue': ^8.48.0 | ||
| '@sentry/vue': ^10.32.1 | ||
| '@sparkjsdev/spark': ^0.1.10 | ||
| '@storybook/addon-docs': ^10.1.9 | ||
| '@storybook/vue3': ^10.1.9 | ||
|
|
@@ -39,8 +39,8 @@ catalog: | |
| '@types/semver': ^7.7.0 | ||
| '@types/three': ^0.169.0 | ||
| '@vitejs/plugin-vue': ^6.0.0 | ||
| '@vitest/coverage-v8': ^3.2.4 | ||
| '@vitest/ui': ^3.2.0 | ||
| '@vitest/coverage-v8': ^4.0.16 | ||
| '@vitest/ui': ^4.0.16 | ||
| '@vue/test-utils': ^2.4.6 | ||
| '@vueuse/core': ^11.0.0 | ||
| '@vueuse/integrations': ^13.9.0 | ||
|
|
@@ -59,11 +59,11 @@ catalog: | |
| eslint-plugin-unused-imports: ^4.3.0 | ||
| eslint-plugin-vue: ^10.6.2 | ||
| firebase: ^11.6.0 | ||
| globals: ^15.9.0 | ||
| happy-dom: ^15.11.0 | ||
| globals: ^16.5.0 | ||
| happy-dom: ^20.0.11 | ||
| husky: ^9.1.7 | ||
| jiti: 2.6.1 | ||
| jsdom: ^26.1.0 | ||
| jsdom: ^27.4.0 | ||
| knip: ^5.75.1 | ||
| lint-staged: ^16.2.7 | ||
| markdown-table: ^3.0.4 | ||
|
|
@@ -72,7 +72,7 @@ catalog: | |
| oxlint: ^1.33.0 | ||
| oxlint-tsgolint: ^0.9.1 | ||
| picocolors: ^1.1.1 | ||
| pinia: ^2.1.7 | ||
| pinia: ^3.0.4 | ||
|
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. Won't this change be the more important one? Wonder what this major change included in pinia
Contributor
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. |
||
| postcss-html: ^1.8.0 | ||
| prettier: ^3.7.4 | ||
| pretty-bytes: ^7.1.0 | ||
|
|
@@ -96,13 +96,13 @@ catalog: | |
| vite-plugin-dts: ^4.5.4 | ||
| vite-plugin-html: ^3.2.2 | ||
| vite-plugin-vue-devtools: ^8.0.0 | ||
| vitest: ^3.2.4 | ||
| vitest: ^4.0.16 | ||
| vue: ^3.5.13 | ||
| vue-component-type-helpers: ^3.0.7 | ||
| vue-component-type-helpers: ^3.2.1 | ||
| vue-eslint-parser: ^10.2.0 | ||
| vue-i18n: ^9.14.3 | ||
| vue-router: ^4.4.3 | ||
| vue-tsc: ^3.1.8 | ||
| vue-tsc: ^3.2.1 | ||
| vuefire: ^3.2.1 | ||
| yjs: ^13.6.27 | ||
| zod: ^3.23.8 | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,8 +3,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | |||||||||||||||||||||||||||
| import { useCachedRequest } from '@/composables/useCachedRequest' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| describe('useCachedRequest', () => { | ||||||||||||||||||||||||||||
| let mockRequestFn: ReturnType<typeof vi.fn> | ||||||||||||||||||||||||||||
| let abortSpy: ReturnType<typeof vi.fn> | ||||||||||||||||||||||||||||
| let mockRequestFn: ( | ||||||||||||||||||||||||||||
| params: any, | ||||||||||||||||||||||||||||
| signal?: AbortSignal | ||||||||||||||||||||||||||||
| ) => Promise<unknown | null> | ||||||||||||||||||||||||||||
| let abortSpy: () => void | ||||||||||||||||||||||||||||
|
Comment on lines
+6
to
+10
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. 🧹 Nitpick | 🔵 Trivial Consider leveraging Vitest's typed mock utilities for improved type safety. The explicit type annotations improve clarity for the Vitest v4 upgrade. However, there's a minor inconsistency: the type signature includes Additionally, the use of 🔎 Suggested refactor for improved type safety- let mockRequestFn: (
- params: any,
- signal?: AbortSignal
- ) => Promise<unknown | null>
- let abortSpy: () => void
+ let mockRequestFn: ReturnType<typeof vi.fn<[params: unknown, signal?: AbortSignal], Promise<unknown | null>>>
+ let abortSpy: ReturnType<typeof vi.fn<[], void>>And update the implementation to include the signal parameter for consistency: - mockRequestFn = vi.fn(async (params: any) => {
+ mockRequestFn = vi.fn(async (params: unknown, signal?: AbortSignal) => {As per coding guidelines, avoid using 📝 Committable suggestion
Suggested change
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| beforeEach(() => { | ||||||||||||||||||||||||||||
| vi.clearAllMocks() | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Comfy-Org/ComfyUI_frontend
Length of output: 98
🏁 Script executed:
Repository: Comfy-Org/ComfyUI_frontend
Length of output: 89
🏁 Script executed:
Repository: Comfy-Org/ComfyUI_frontend
Length of output: 2992
🌐 Web query:
Vitest v4 happy-dom jsdom globals compatibility requirements💡 Result:
Short summary — Vitest v4 compatibility with happy-dom / jsdom and globals
Environments: Vitest supports both jsdom and happy-dom as test environments; you must install the chosen package yourself (npm i -D jsdom or happy-dom) and set test.environment to 'jsdom' or 'happy-dom'. [1][2]
environmentOptions: Vitest v4 accepts per-environment options (keys: jsdom and happyDOM) via test.environmentOptions to pass options into the environment setup. [3]
Globals: Vitest does not enable Jest-style globals by default. Enable them with test.globals = true (or --globals) if you want window/document/test APIs injected as globals; otherwise import from 'vitest'. [4]
API differences: happy-dom is generally faster but may lack some browser APIs that jsdom implements; choose jsdom for wider API coverage or happy-dom for speed and configure specific tests if needed. vi.stubGlobal/unstubAllGlobals affects both globalThis and window when using jsdom/happy-dom. [1][2]
References
🌐 Web query:
happy-dom v20 breaking changes release notes💡 Result:
Summary — happy-dom v20 breaking changes
Sources
References
[1] https://github.com/capricorn86/happy-dom/releases.
[2] GHSA-37j7-fg3j-429f.
🌐 Web query:
jsdom v27 vitest compatibility breaking changes💡 Result:
Short summary of jsdom v27 breaking changes that have caused Vitest test failures and compatibility issues — and quick mitigations.
What changed in jsdom v27 (relevant points)
Observed Vitest impacts and causes
Quick mitigations
Sources
[1] jsdom v27 release notes / changelog (summary including Node 20 minimum).
[2] jsdom releases page (v27.0.0 → 27.x detailed changelog).
[3] Community writeup reporting Vitest test failures after jsdom v27.
[4] Vitest introduces Browser Mode (alternative to jsdom).
[5] Vitest issues discussing jsdom/environment resolution and related test failures.
If you want, I can:
Address breaking changes in test environment package upgrades.
The test environment packages have breaking changes that require test updates:
element.click()), modifies CSS/UA stylesheet handling, makes some event listeners passive by default, and alters cookie security handling. Community reports indicate many test suites broke after this upgrade.enableJavaScriptEvaluation: trueif tests rely on it.Audit tests for assumptions about event types, passive event behavior, UA stylesheet dependencies, and any eval-based code before merging.