Skip to content

Commit 2191c84

Browse files
authored
chore: migrate test runner from Jest to Vitest (#617)
Replace `jest` + `ts-jest` with `vitest` for faster, more reliable test execution. Drops Node 16 from the CI checks (incompatibility w/ latest Vitest through missing `crypto` API). Closes #612
1 parent ea53725 commit 2191c84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+7397
-8806
lines changed

.github/workflows/test_and_release.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node-version: [ 16, 18, 20, 22 ]
18+
node-version: [ 18, 20, 22 ]
1919

2020
steps:
2121
- uses: actions/checkout@v6
@@ -42,7 +42,7 @@ jobs:
4242

4343
steps:
4444
- uses: actions/checkout@v6
45-
- name: Use Node.js 20
45+
- name: Use Node.js
4646
uses: actions/setup-node@v6
4747
with:
4848
node-version: 24
@@ -68,7 +68,7 @@ jobs:
6868

6969
steps:
7070
- uses: actions/checkout@v6
71-
- name: Use Node.js 20
71+
- name: Use Node.js
7272
uses: actions/setup-node@v6
7373
with:
7474
node-version: 24
@@ -108,6 +108,6 @@ jobs:
108108
with:
109109
workflow: publish_to_npm.yaml
110110
inputs: >
111-
{
112-
"ref": "master"
111+
{
112+
"ref": "master"
113113
}

CLAUDE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ Internal Apify monorepo of shared TypeScript utilities and constants published a
1111
```bash
1212
npm install # Install all dependencies
1313
npm run build # Build all packages (lerna run build)
14-
npm test # Run all tests (jest --silent)
14+
npm test # Run all tests (vitest)
1515
npm run test-cov # Run tests with coverage
16-
npx jest test/consts.test.ts # Run a single test file
17-
npx jest test/consts.test.ts -t "pattern" # Run specific test by name
16+
npx vitest run test/consts.test.ts # Run a single test file
17+
npx vitest run test/consts.test.ts -t "pattern" # Run specific test by name
1818
npm run lint # Lint all source and test files
1919
npm run lint:fix # Lint with auto-fix
2020
npm run clean # Clean all dist/ folders
@@ -29,10 +29,10 @@ npm run clean # Clean all dist/ folders
2929

3030
## Key Conventions
3131

32-
- **Imports in tests:** Always use absolute package names (`@apify/consts`, not relative paths to package sources). Jest's `moduleNameMapper` resolves `@apify/*` to `packages/*/src`
32+
- **Imports in tests:** Always use absolute package names (`@apify/consts`, not relative paths to package sources). Vitest's `resolve.alias` resolves `@apify/*` to `packages/*/src`
3333
- **Cross-package imports in source:** Use absolute `@apify/*` paths. Within the same package, use relative imports. Never self-import a package by its own `@apify/*` name
3434
- **Dev dependencies** go in the root `package.json` only. Runtime dependencies go in each package's own `package.json`
35-
- **No build needed for tests**ts-jest compiles TypeScript directly from source
35+
- **No build needed for tests**Vitest compiles TypeScript directly from source via esbuild
3636
- **Conventional commits** required: `fix:` (patch), `feat:` (minor), `BREAKING CHANGE:` in footer (major). Enforced by commitlint + husky hooks. PR titles must also follow this format
3737
- **Adding a new package:** Copy an existing package directory, update `package.json` name/deps, keep the standard `build`/`clean`/`compile`/`copy` scripts
3838
- Package dependencies must be declared in `package.json` so Lerna builds in correct topological order

jest.config.js

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

0 commit comments

Comments
 (0)