feat: support vitest unit tests - #6123
Conversation
📝 WalkthroughWalkthroughThe CLI now supports Vitest initialization and execution for NativeScript runtime, UI, and visionOS tests. It adds dependencies, resources, Android network configuration, framework detection, command routing, and documentation while preserving the Karma flow with deprecation notices. ChangesVitest testing integration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant TestCommandBase
participant VitestExecutionService
participant Vitest
TestCommandBase->>VitestExecutionService: detect project and validate readiness
VitestExecutionService->>Vitest: start platform-specific non-watch run
Vitest-->>VitestExecutionService: return process status
VitestExecutionService-->>TestCommandBase: complete or report failure
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@config/test-dependencies.json`:
- Around line 3-22: Regenerate the generated dependency registry from
config/test-dependencies.json using scripts/generate-test-deps.js, and include
the resulting config/test-deps-versions-generated.json with entries for vitest,
`@vitest/runner`, `@nativescript/unit-test-runner`, and
`@valor/nativescript-websockets` so ns test init --framework vitest can resolve
them.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cbfc56e8-3737-417e-9205-85df7cbd4fbd
📒 Files selected for processing (16)
config/test-dependencies.jsondocs/man_pages/project/testing/test-init.mdlib/bootstrap.tslib/commands/test-init.tslib/commands/test.tslib/common/declarations.d.tslib/constants.tslib/definitions/project.d.tslib/services/test-initialization-service.tslib/services/vitest-execution-service.tsresources/test/example.vitest.jsresources/test/example.vitest.tsresources/test/network_security.xmlresources/test/test-main.vitest.jsresources/test/test-main.vitest.tsresources/test/vitest.config.mts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/man_pages/project/testing/test-visionos.md`:
- Line 46: Insert a blank line immediately before the `<% } %>` template
directive in the Markdown table section so the table is terminated before the
directive and markdownlint MD056 no longer treats it as a table row.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 10473ce5-0101-4493-9052-9b4c7954cabe
📒 Files selected for processing (9)
docs/man_pages/project/testing/test-android.mddocs/man_pages/project/testing/test-init.mddocs/man_pages/project/testing/test-ios.mddocs/man_pages/project/testing/test-visionos.mddocs/man_pages/project/testing/test.mdlib/bootstrap.tslib/commands/test-init.tslib/commands/test.tsresources/test/vitest.config.mts
🚧 Files skipped from review as they are similar to previous changes (4)
- lib/bootstrap.ts
- resources/test/vitest.config.mts
- docs/man_pages/project/testing/test-init.md
- lib/commands/test-init.ts
| [test init](test-init.html) | Configures your project for unit testing with a selected framework. | ||
| [test android](test-android.html) | Runs the tests in your project on Android devices or native emulators. | ||
| [test ios](test-ios.html) | Runs the tests in your project on iOS devices or the iOS Simulator. | ||
| <% } %> |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
End the Markdown table before the template directive.
Line 46 is parsed as a one-column table row. markdownlint-cli2 reports MD056. Insert a blank line before <% } %>.
Proposed fix
[test ios](test-ios.html) | Runs the tests in your project on iOS devices or the iOS Simulator.
+
<% } %>🧰 Tools
🪛 markdownlint-cli2 (0.23.2)
[warning] 46-46: Table column count
Expected: 2; Actual: 1; Too few cells, row will be missing data
(MD056, table-column-count)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/man_pages/project/testing/test-visionos.md` at line 46, Insert a blank
line immediately before the `<% } %>` template directive in the Markdown table
section so the table is terminated before the directive and markdownlint MD056
no longer treats it as a table row.
Source: Linters/SAST tools
Support Vitest as first class default option on unit testing. Other options are still options as well on init.
Companion for NativeScript/nativescript-unit-test-runner#80
Summary by CodeRabbit
New Features
Documentation
Bug Fixes