-
Notifications
You must be signed in to change notification settings - Fork 265
Migrate thunder-gate tests to Vitest Browser Mode and Vitest v4 #1264
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
base: main
Are you sure you want to change the base?
Migrate thunder-gate tests to Vitest Browser Mode and Vitest v4 #1264
Conversation
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.
Pull request overview
This pull request migrates thunder-gate tests from @testing-library/react with JSDOM to Vitest Browser Mode with Playwright, running tests in actual Chromium browsers. This addresses limitations of JSDOM that don't fully reflect real browser behavior and eliminates the need for extensive DOM API mocking.
Changes:
- Added browser-specific test utilities to @thunder/test-utils package (browser.ts, browser-test-utils.tsx, setup-browser.ts)
- Configured Vitest with Playwright provider for thunder-gate tests
- Migrated all 18 test files from @testing-library APIs to native Vitest Browser Mode APIs (page object, userEvent, expect.element, expect.poll)
- Implemented vi.hoisted() pattern for proper mock function hoisting in browser mode
- Removed @testing-library dependencies from thunder-gate and replaced with playwright and @vitest/browser packages
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/pnpm-workspace.yaml | Added @vitest/browser, @vitest/browser-playwright, playwright, and vitest-browser-react to catalog |
| frontend/pnpm-lock.yaml | Updated dependency resolution for new browser mode packages |
| frontend/packages/thunder-test-utils/src/setup-browser.ts | Browser mode test setup with i18n and Asgardeo mocks |
| frontend/packages/thunder-test-utils/src/browser.ts | Exports browser-specific test utilities and Vitest Browser Mode APIs |
| frontend/packages/thunder-test-utils/src/browser-test-utils.tsx | Implements custom render and renderHook functions for browser mode with provider wrapping |
| frontend/packages/thunder-test-utils/rolldown.config.js | Added build configuration for browser mode utilities (ESM only) |
| frontend/packages/thunder-test-utils/package.json | Added package exports for ./browser and ./setup-browser, added vitest-browser-react dependency |
| frontend/apps/thunder-gate/vite.config.ts | Configured browser mode with Playwright provider, chromium browser, and headless mode |
| frontend/apps/thunder-gate/src/test/setup.ts | Updated to import setup-browser instead of jsdom setup |
| frontend/apps/thunder-gate/src/tests/**/*.test.tsx | Migrated 18 test files to use page object queries, userEvent, expect.element, and expect.poll |
| frontend/apps/thunder-gate/package.json | Removed @testing-library dependencies, added @vitest/browser, playwright, and vitest-browser-react |
| .gitignore | Added screenshots directory to ignore Vitest Browser Mode screenshots |
Files not reviewed (1)
- frontend/pnpm-lock.yaml: Language not supported
frontend/packages/thunder-test-utils/src/browser-test-utils.tsx
Outdated
Show resolved
Hide resolved
frontend/apps/thunder-gate/src/__tests__/pages/SignUpPage.test.tsx
Outdated
Show resolved
Hide resolved
frontend/packages/thunder-test-utils/src/browser-test-utils.tsx
Outdated
Show resolved
Hide resolved
4e2dc4c to
82b5a29
Compare
82b5a29 to
aba20f4
Compare
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.
Pull request overview
Copilot reviewed 25 out of 27 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- frontend/pnpm-lock.yaml: Language not supported
aba20f4 to
10db431
Compare
10db431 to
851acd7
Compare
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.
Pull request overview
Copilot reviewed 25 out of 27 changed files in this pull request and generated 4 comments.
Files not reviewed (1)
- frontend/pnpm-lock.yaml: Language not supported
frontend/apps/thunder-gate/src/__tests__/AppWithConfig.test.tsx
Outdated
Show resolved
Hide resolved
6394e1b to
e4d67f0
Compare
e4d67f0 to
7bc8dc6
Compare
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.
Pull request overview
Copilot reviewed 53 out of 55 changed files in this pull request and generated 4 comments.
Files not reviewed (1)
- frontend/pnpm-lock.yaml: Language not supported
...d/apps/thunder-develop/src/features/applications/api/__tests__/useCreateApplication.test.tsx
Show resolved
Hide resolved
...ponents/resource-property-panel/rich-text/helper-plugins/__tests__/CustomLinkPlugin.test.tsx
Show resolved
Hide resolved
7bc8dc6 to
b50426a
Compare
b50426a to
e579ed1
Compare
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.
Pull request overview
Copilot reviewed 55 out of 57 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- frontend/pnpm-lock.yaml: Language not supported
e579ed1 to
6f6f777
Compare
Purpose
This pull request refactors test and component code throughout the
thunder-developfrontend to improve type safety and clarity when working with mock functions. The main change is replacing the use ofReturnType<typeof vi.fn>with the explicitMocktype imported fromvitest. This makes mock variable types more accurate and consistent, especially in test files. Additionally, one minor improvement updates auseReftype for better compatibility.The most important changes are:
Test type improvements:
ReturnType<typeof vi.fn>with the explicitMocktype for mock variables in test files across applications and flows features, including API and component tests.Component type improvement:
applyTimeoutRefinEditTokenSettings.tsxfromNodeJS.Timeout | nulltoReturnType<typeof setTimeout> | nullfor better compatibility across environments.These changes enhance code maintainability and reduce the risk of type errors when working with mocks in tests.
Related Issues
@testing-library/*+ Migrate toVitest Browser Modefor browser based testing #1261Related PRs
Checklist
breaking changelabel added.Security checks