Skip to content

Commit 686dfcc

Browse files
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 Codecov
1 parent f4caa0e commit 686dfcc

File tree

364 files changed

+1955
-36005
lines changed

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 changed

β€Ž.babelrc.jsβ€Ž

Lines changed: 0 additions & 34 deletions
This file was deleted.

β€Ž.github/actions/setup-node/action.ymlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ runs:
1111
using: 'composite'
1212
steps:
1313
- name: Setup Node
14-
uses: actions/setup-node@v4
14+
uses: actions/setup-node@v6
1515
with:
1616
node-version: ${{ inputs.node-version }}
1717

@@ -20,7 +20,7 @@ runs:
2020
run: echo "NODE_VERSION=$(node --version)" >> $GITHUB_ENV
2121

2222
- name: Cache dependencies
23-
uses: actions/cache@v4
23+
uses: actions/cache@v5
2424
with:
2525
path: ./node_modules
2626
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('./yarn.lock') }}

β€Ž.github/workflows/ci.ymlβ€Ž

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
name: TypeScript
99
steps:
10-
- uses: actions/checkout@v4
10+
- uses: actions/checkout@v6
1111

1212
- uses: ./.github/actions/setup-node
1313

@@ -18,21 +18,24 @@ jobs:
1818
runs-on: ubuntu-latest
1919
name: Lint & test with Node
2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v6
2222

2323
- uses: ./.github/actions/setup-node
2424

2525
- name: Build SDK
2626
run: yarn build
2727

2828
- name: πŸ§ͺ Lint and test with Node ${{ env.NODE_VERSION }}
29-
env:
30-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3129
run: |
3230
yarn lint
3331
yarn coverage
3432
yarn validate-translations
3533
34+
- name: Upload coverage to Codecov
35+
uses: codecov/codecov-action@v5
36+
with:
37+
token: ${{ secrets.CODECOV_TOKEN }}
38+
3639
- name: πŸ§ͺ Validate CommonJS bundle with Node ${{ env.NODE_VERSION }}
3740
run: yarn validate-cjs
3841

@@ -45,7 +48,7 @@ jobs:
4548
VITE_STREAM_API_KEY: ${{ vars.VITE_STREAM_API_KEY }}
4649
NODE_ENV: production
4750
steps:
48-
- uses: actions/checkout@v4
51+
- uses: actions/checkout@v6
4952

5053
- uses: ./.github/actions/setup-node
5154
env:

β€Ž.github/workflows/e2e.ymlβ€Ž

Lines changed: 0 additions & 54 deletions
This file was deleted.

β€Ž.github/workflows/pr-check.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
pr-title:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v6
1212

1313
- uses: ./.github/actions/setup-node
1414

β€Ž.github/workflows/release.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
if: ${{ inputs.dry_run || startsWith(github.ref_name, 'release') || startsWith(github.ref_name, 'master') || startsWith(github.ref_name, 'rc')}}
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@v6
2525
with:
2626
fetch-depth: 0
2727

β€Ž.github/workflows/size.ymlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- master
77
paths-ignore:
8-
- '**.test.js'
8+
- '**.test.*'
99
- '**.md'
1010
env:
1111
NODE_OPTIONS: --max_old_space_size=4096
@@ -14,7 +14,7 @@ jobs:
1414
build:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818
- uses: preactjs/compressed-size-action@v2
1919
env:
2020
NODE_OPTIONS: --max_old_space_size=4096

β€Ž.ladle/components.tsxβ€Ž

Lines changed: 0 additions & 9 deletions
This file was deleted.

β€Ž.ladle/config.mjsβ€Ž

Lines changed: 0 additions & 4 deletions
This file was deleted.

β€Ž.ladle/styles.cssβ€Ž

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
Β (0)