-
Notifications
You must be signed in to change notification settings - Fork 82
Feat/migrate jest to vitest #346
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
Feat/migrate jest to vitest #346
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- replace jest with vitest - remove jest references no longer used - add vitest configuration file in package - add vitest configuration file to workspace
- replace jest with vitest - remove jest references no longer used - add vitest configuration file in package - refactor extend functions so that they work with vitest - rename jest extensions file as `VitestExtensions.ts` - add vitest types
- replace jest with vitest - add vitest configuration file in package - remove jest configuration file
- remove tests scripts from package.json - delete tsconfig.test.json config file no longer needed - add vitest api as global so that import is no required such as describe, expect, it, etc.
- remove tests scripts from package.json - delete tsconfig.test.json config file no longer needed - add vitest api as global so that import is no required such as describe, expect, it, etc.
- remove tests scripts from package.json - delete tsconfig.test.json config file no longer needed - add vitest api as global so that import is no required such as describe, expect, it, etc.
- replace jest with vitest in examples/testing-suite - remove jest dependencies - install vitest dev dependency - replace jest config files with vitest config files
- pass vitest flags to test execution
1d312b7 to
026064d
Compare
remove extra blank line
remove extra blank line
remove extra blank line
remove extra blank line
remove extra blank line
- add globals: true to vitest.config.ts on main path of workspace
|
@rkalis is attempting to deploy a commit to the Kalis Software Team on Vercel. A member of the Team first needs to authorize it. |
65c89b0 to
c24889d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #346 +/- ##
==========================================
+ Coverage 97.42% 99.54% +2.12%
==========================================
Files 76 8 -68
Lines 16929 222 -16707
Branches 1241 10 -1231
==========================================
- Hits 16493 221 -16272
+ Misses 426 1 -425
+ Partials 10 0 -10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 migrates the automated testing framework from Jest to Vitest across the entire monorepo, addressing issue #228. The migration includes updating test configurations, refactoring test utilities, and updating all test files to use Vitest APIs while maintaining backward compatibility for external consumers.
Key Changes
- Replaced Jest with Vitest as the test framework across all packages (cashscript, cashc, utils) and examples
- Updated test configurations with workspace-level vitest.config.ts and package-specific configurations
- Migrated custom test matchers (toLog, toFailRequire, toFailRequireWith) from Jest to Vitest while maintaining compatibility through both jest/ and vitest/ export paths
- Refactored conditional test execution from custom
itOrSkip/describeOrSkiphelpers to Vitest's nativeit.runIf/it.skipIf/describe.runIf/describe.skipIfAPIs
Reviewed changes
Copilot reviewed 50 out of 54 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Root workspace configuration that references package-level vitest configs |
| tsconfig.build.json | Updated to use vitest/globals types instead of jest, upgraded lib from es2021 to es2022 |
| packages/utils/vitest.config.ts | New Vitest configuration for utils package with v8 coverage provider |
| packages/utils/package.json | Removed Jest dependencies and scripts, added Vitest dependencies and simplified test command |
| packages/utils/tsconfig.test.json | Removed separate test TypeScript config (no longer needed with Vitest) |
| packages/utils/jest.config.js | Deleted Jest configuration file |
| packages/cashscript/vitest.config.ts | New Vitest configuration for cashscript package with test setup files |
| packages/cashscript/vitest.setup.ts | Setup file that imports TestExtensions and configures inspect depth |
| packages/cashscript/vitest/package.json | Export configuration for vitest import path |
| packages/cashscript/package.json | Migrated from Jest to Vitest dependencies and updated test scripts |
| packages/cashscript/jest/package.json | Updated to reference TestExtensions for backward compatibility |
| packages/cashscript/jest.config.js | Deleted Jest configuration file |
| packages/cashscript/src/test/TestExtensions.ts | Refactored from JestExtensions to work with both Jest and Vitest, removed async debug() support |
| packages/cashscript/test/*.test.ts | Updated multiple test files to use Vitest APIs (it.each, it.runIf, it.skipIf, vi.fn, vi.spyOn) |
| packages/cashscript/test/test-util.ts | Removed custom itOrSkip and describeOrSkip helpers |
| packages/cashc/vitest.config.ts | New Vitest configuration for cashc package |
| packages/cashc/vitest.setup.ts | Setup file for cashc tests |
| packages/cashc/package.json | Migrated dependencies and scripts from Jest to Vitest |
| packages/cashc/jest.config.js | Deleted Jest configuration file |
| examples/testing-suite/vitest.config.ts | New Vitest configuration for testing suite example |
| examples/testing-suite/package.json | Updated dependencies and scripts for Vitest |
| examples/testing-suite/test/example.test.ts | Updated import from 'cashscript/jest' to 'cashscript/vitest' |
| examples/testing-suite/artifacts/example.json | Updated artifact timestamp |
| package.json | Removed root-level Jest dependencies |
| jest/log-on-fail-reporter.cjs | Deleted custom Jest reporter |
| jest/summary-reporter.cjs | Deleted custom Jest reporter |
| .github/workflows/github-actions.yml | Updated CI test command to use Vitest coverage syntax |
| .eslintrc.cjs | Removed jest environment configuration |
| .eslintignore | Removed dist-test directories from ignore patterns |
| .gitignore | Removed dist-test directories (no longer generated) |
| .cspell.json | Removed dist-test from spell check exclusions |
Comments suppressed due to low confidence (1)
packages/cashscript/src/test/TestExtensions.ts:11
- The namespace is still named 'jest' even though the codebase has migrated to Vitest. This should be updated to use Vitest's type system. Consider using Vitest's expect type extension mechanism directly or renaming the namespace to 'vitest' to better reflect the current test framework.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @hereje, thank you very much for this PR! We weren't able to get to it immediately, but this is something that we've wanted to have for a really long time and will improve our developer experience tremendously! 🫡 We have a contributor's fund to reward code contributions like yours, so if you have a BCH address, please send it to me on Telegram or X (RoscoKalis), so we can send some BCH your way! |
My pleasure. Well, I'll reach you out through X. |
Moving automated tests to Vitest
Fixes: #228