Add Vitest test command and run unit tests #380
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Vitest test command and run unit tests
Summary
This PR adds a proper test runner setup using Vitest for the PVM Debugger project. Previously, the project had unit tests in
src/packages/pvm/jam-codec/but no npm script to run them.Changes:
package.jsonnpm run testandnpm run test:watchscriptsvitest.config.tsto run unit tests undersrc/while excluding Playwright E2E tests intests/node:testimports tovitestimportspackage-lock.jsonwith new dependenciesThe unit tests now run via
npm run testand all 31 tests pass (2 test files covering JAM codec functionality).Review & Testing Checklist for Human
npm run testlocally - Verify it executes and all tests pass (should show 2 files, 31 tests)npm run test:watchto ensure watch mode works correctlyRecommended test plan:
rm -rf node_modules package-lock.json && npm installnpm run test(expect 31 passing tests)npm run lint(should pass)Diagram
%%{ init : { "theme" : "default" }}%% flowchart TD PJ["package.json<br/>Scripts + Dependencies"]:::major-edit VC["vitest.config.ts<br/>Test Configuration"]:::major-edit T1["src/packages/pvm/jam-codec/<br/>little-endian-decoder.test.ts"]:::minor-edit T2["src/packages/pvm/jam-codec/<br/>decode-natural-number.test.ts"]:::minor-edit E2E["tests/<br/>Playwright E2E Tests"]:::context PJ -->|"defines test scripts"| VC VC -->|"includes"| T1 VC -->|"includes"| T2 VC -->|"excludes"| E2E subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Link to Devin run: https://app.devin.ai/sessions/32696a16f4d549ffbd30d1b02a60040c
Requested by: Tomek (@tomusdrw)
The migration from
node:testtovitestwas minimal - only import statements changed, not test logic. However, different test runners can have subtle behavioral differences, so human verification is recommended. The vitest config intentionally separates unit tests (src/) from E2E tests (tests/) to avoid conflicts.