-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: switching from jest
to vitest
and adding "test:bench" and "test:coverage" scripts
#1015
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?
Conversation
…test:coverage" scripts
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 PR modernizes the test infrastructure by switching from Jest to Vitest, which provides significantly faster test execution (from 3.5s to 0.9s) and includes built-in benchmark and coverage capabilities. The change improves developer productivity with enhanced testing tools while maintaining full compatibility with existing test functionality.
- Replaced Jest test runner with Vitest for better performance and modern features
- Added new npm scripts for benchmarking and coverage reporting
- Updated all test files to use Vitest imports and mocking APIs
Reviewed Changes
Copilot reviewed 43 out of 45 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
vitest.config.ts | New Vitest configuration with mock aliasing and coverage settings |
package.json | Updated dependencies and scripts to use Vitest instead of Jest |
tsconfig.*.json | Added .bench.ts exclusions for benchmark test files |
src/**/*.test.ts | Updated test imports and mocking to use Vitest APIs |
eslint.config.mjs | Added .bench.ts to ignored patterns |
CLAUDE.md | Updated documentation to reflect new testing commands |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- run: npm run build | ||
- run: npm test | ||
- run: npm run test:coverage | ||
- uses: davelosert/vitest-coverage-report-action@v2 |
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.
Not sure about using a 3rd party GitHub Action, and whether this will create comment spam on PRs. Up to TypeScript SDK maintainers though.
We also might want to pin the version
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.
Was also thinking about this.
We can get coverage sorted without it.
"outDir": "./dist/esm" | ||
}, | ||
"exclude": ["**/*.test.ts", "src/__mocks__/**/*"] | ||
"exclude": ["**/*.bench.ts", "**/*.test.ts", "src/__mocks__/**/*"] |
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.
What is bench.ts? Since we dont have any benchmark tests, should we keep it?
- run: npm run build | ||
- run: npm test | ||
- run: npm run test:coverage | ||
- uses: davelosert/vitest-coverage-report-action@v2 |
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.
Was also thinking about this.
We can get coverage sorted without it.
Followup to #916 as discussed with @KKonstantinov .
Vitest is faster than Jest (from 3.5s to 0.9s) and comes with benchmark and coverage features, smart watch mode, better ESM support, and an easy switch.
Motivation and Context
Better test tooling
How Has This Been Tested?
Running the test suite, confirming the same number of tests ran, all of them passed, and the execution time was significantly less.
Breaking Changes
None
Types of changes
Checklist
Additional context