chore: Migrate to vitest (#12272)

* wip

* Remove obsolete snapshots

* simplify

* chore(test): Convert mocks to TypeScript and tighten fetch mock types

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* Remove unneccessary patches

* Migrate to msw instead of custom fetch mock

* Address PR review comments

- Split chained vi.useFakeTimers().setSystemTime() into separate calls.
- Switch test setup to dynamic imports so EventEmitter.defaultMaxListeners
  assignment runs before module init (static imports were hoisted above it).
- Drop redundant NODE_ENV guard in monkeyPatchSequelizeErrorsForJest; its
  sole caller already gates on env.isTest.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Tom Moor
2026-05-06 21:10:51 -04:00
committed by GitHub
parent 0139b91b5d
commit 091346dfe8
91 changed files with 2298 additions and 2961 deletions
+3 -18
View File
@@ -34,6 +34,7 @@ jobs:
config:
- '.github/**'
- 'vite.config.ts'
- 'vitest.config.ts'
server:
- 'server/**'
- 'shared/**'
@@ -82,15 +83,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/install
- name: Restore Jest transform cache
uses: actions/cache@v4
with:
path: /tmp/jest_runner
key: jest-${{ matrix.test-group }}-${{ hashFiles('.babelrc', '.jestconfig.json', 'yarn.lock', 'app/**/*.ts', 'app/**/*.tsx', 'shared/**/*.ts', 'shared/**/*.tsx') }}
restore-keys: |
jest-${{ matrix.test-group }}-${{ hashFiles('.babelrc', '.jestconfig.json', 'yarn.lock') }}-
jest-${{ matrix.test-group }}-
- run: yarn test:${{ matrix.test-group }} --cacheDirectory=/tmp/jest_runner
- run: yarn test:${{ matrix.test-group }}
test-server:
needs: changes
@@ -118,17 +111,9 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/install
- name: Restore Jest transform cache
uses: actions/cache@v4
with:
path: /tmp/jest_runner
key: jest-server-${{ matrix.shard }}-${{ hashFiles('.babelrc', '.jestconfig.json', 'yarn.lock', 'server/**/*.ts', 'shared/**/*.ts', 'plugins/**/*.ts') }}
restore-keys: |
jest-server-${{ matrix.shard }}-${{ hashFiles('.babelrc', '.jestconfig.json', 'yarn.lock') }}-
jest-server-${{ matrix.shard }}-
- run: yarn sequelize db:migrate
- name: Run server tests
run: yarn test:server --maxWorkers=2 --shard=${{ matrix.shard }}/4 --cacheDirectory=/tmp/jest_runner
run: yarn test:server --maxWorkers=2 --shard=${{ matrix.shard }}/4
bundle-size:
needs: changes