Commit 686dfcc
authored
chore: migrate test infrastructure from Jest to Vitest (#3047)
## Summary
- **Migrate test infrastructure from Jest to Vitest** β replace Jest,
Babel, and all related config with Vitest 4.x powered by the native Vite
pipeline
- **Rename JSX test files to `.jsx`** β 111 test files + 19 snapshot
files renamed so Vite handles JSX natively, eliminating the custom
`jsxInJs` esbuild plugin
- **Remove legacy example apps** β delete `capacitor`, `nextjs`, and
`website-demos` examples (keeping only `vite` and `tutorial`)
- **Remove E2E/Ladle infrastructure** β delete Playwright E2E tests,
Ladle stories, and all related config
- **Tidy ESLint config** β migrate to flat config, remove Jest plugin,
add Vitest plugin
- **Restore Codecov integration** β add the missing
`codecov/codecov-action` upload step to CI
- **Clean up unused dependencies** β remove `@axe-core/react`,
`@types/dotenv`, `@types/uuid`, `@types/deep-equal`, `@types/moment`,
`@types/textarea-caret`, `@types/lodash.defaultsdeep`, `autoprefixer`,
`dotenv`
- **Update GitHub Actions** β `actions/checkout` v4βv6,
`actions/setup-node` v4βv6, `actions/cache` v4βv5
### Details
**Test migration**:
- All `jest.fn()` / `jest.spyOn()` β `vi.fn()` / `vi.spyOn()`
- `jest.mock()` β `vi.mock()` with `async importOriginal` pattern
- Replaced `jest.useFakeTimers()` / `jest.useRealTimers()` with Vitest
equivalents
- Updated timer advancing (`jest.advanceTimersByTime` β
`vi.advanceTimersByTime`, etc.)
- Fixed `mockImplementation()` no-arg calls that behave differently in
Vitest (β `mockResolvedValue()`)
- Setup file: `jest.env.setup.js` β `vitest.setup.ts` with
`@testing-library/jest-dom/vitest` and `vitest-axe`
- Coverage: v8 provider scoped to `src/**/*.{ts,tsx,js,jsx}`, excludes
`@types`, tests, mock-builders
**JSX file rename**:
- Renamed 111 `.test.js` β `.test.jsx` and 19 `.test.js.snap` β
`.test.jsx.snap`
- Removed custom `jsxInJs()` esbuild pre-transform plugin from
`vitest.config.ts`
- Vite now handles JSX natively via file extension β no double-transform
overhead
**Removed configs**: `.babelrc.js`, `babel.config.js`, `jest.config.js`,
`jest-global-setup.js`, `assetsTransformer.js`, `playwright.config.ts`,
`tsconfig.test.json` (simplified)
## Test plan
- [ ] `yarn test` β all unit tests pass with no unhandled errors
- [ ] `yarn coverage` β generates coverage report with correct file
scoping
- [ ] `yarn lint` β no lint errors
- [ ] `yarn types` β TypeScript passes
- [ ] `yarn build` β build succeeds
- [ ] CI workflow runs tests and uploads coverage to Codecov1 parent f4caa0e commit 686dfcc
File tree
364 files changed
+1955
-36005
lines changed- .github
- actions/setup-node
- workflows
- .ladle
- developers
- e2e
- fixtures
- data
- scripts
- user
- components
- Attachment
- EditMessageForm
- MessageActions
- MessageList
- Message
- Thread
- examples
- capacitor
- android
- app
- src
- androidTest/java/com/getcapacitor/myapp
- main
- assets
- java/capacitor/test
- res
- drawable-land-hdpi
- drawable-land-mdpi
- drawable-land-xhdpi
- drawable-land-xxhdpi
- drawable-land-xxxhdpi
- drawable-port-hdpi
- drawable-port-mdpi
- drawable-port-xhdpi
- drawable-port-xxhdpi
- drawable-port-xxxhdpi
- drawable-v24
- drawable
- layout
- mipmap-anydpi-v26
- mipmap-hdpi
- mipmap-mdpi
- mipmap-xhdpi
- mipmap-xxhdpi
- mipmap-xxxhdpi
- values
- xml
- test/java/com/getcapacitor/myapp
- gradle/wrapper
- ios
- App
- App.xcodeproj
- project.xcworkspace
- App.xcworkspace
- App
- Assets.xcassets
- AppIcon.appiconset
- Splash.imageset
- Base.lproj
- public
- src
- components
- nextjs
- pages
- public
- website-demos
- social-messaging
- virtual-event
- src
- components
- Attachment/__tests__
- __snapshots__
- AudioPlayback
- __tests__
- plugins/__tests__
- Avatar/__tests__
- Badge/__tests__
- BaseImage/__tests__
- ChannelHeader/__tests__
- ChannelListItem
- __tests__
- __snapshots__
- hooks/__tests__
- ChannelList/__tests__
- __snapshots__
- Channel/__tests__
- __snapshots__
- ChatView/__tests__
- Chat/__tests__
- DateSeparator/__tests__
- Dialog/__tests__
- EmptyStateIndicator/__tests__
- EventComponent/__tests__
- Form/__tests__
- Gallery/__tests__
- __snapshots__
- InfiniteScrollPaginator/__tests__
- LoadMore/__tests__
- Loading/__tests__
- __snapshots__
- Location/__tests__
- MediaRecorder
- AudioRecorder/__tests__
- __snapshots__
- classes/__tests__
- hooks/__tests__
- observable/__tests__
- MessageActions/__tests__
- MessageComposer
- __tests__
- __snapshots__
- hooks/__tests__
- MessageList
- __tests__
- __snapshots__
- hooks/__tests__
- Message
- __tests__
- __snapshots__
- hooks/__tests__
- renderText/__tests__
- __snapshots__
- Modal/__tests__
- Notifications
- __tests__
- hooks/__tests__
- Poll/__tests__
- Reactions/__tests__
- SafeAnchor/__tests__
- Search/__tests__
- TextareaComposer/__tests__
- Threads/ThreadList/__tests__
- Thread/__tests__
- Tooltip/__tests__
- TypingIndicator
- __tests__
- hooks/__tests__
- Window/__tests__
- i18n/__tests__
- mock-builders
- api
- browser
- stories
- utils/__tests__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
364 files changed
+1955
-36005
lines changedThis file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | | - | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments