Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions config/test-dependencies.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
[
{
"name": "@jsdevtools/coverage-istanbul-loader"
"name": "vitest",
"framework": "vitest",
"version": "~4.1.10"
},
{
"name": "karma"
"name": "@vitest/runner",
"framework": "vitest",
"version": "~4.1.10"
},
{
"name": "karma-coverage"
"name": "@nativescript/unit-test-runner",
"framework": "vitest",
"version": "^5.0.0-alpha.0"
},
{
"name": "karma-nativescript-launcher"
"name": "@valor/nativescript-websockets",
"framework": "vitest",
"version": "^2.0.3",
"saveInDependencies": true
},
Comment on lines +3 to +22

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

registry="$(fd -a '^test-deps-versions-generated\.json$' config | head -n 1)"
test -n "$registry"

jq -e '
  has("vitest") and
  has("`@vitest/runner`") and
  has("`@nativescript/unit-test-runner`") and
  has("`@valor/nativescript-websockets`")
' "$registry"

Repository: NativeScript/nativescript-cli

Length of output: 167


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== candidate files =="
fd -a 'test-dependencies\.json|test-deps-versions-generated\.json|test-initialization-service\.ts' config . | sed 's#^\./##'

echo
echo "== generated registry keys matching Vitest/deps (if file exists) =="
registry="$(fd -a '^test-deps-versions-generated\.json$' config . | head -n 1 || true)"
if [ -n "${registry:-}" ]; then
  jq 'keys' "$registry" | sed -n '1,120p'
  echo
  jq '. | {vitest, runner:."`@vitest/runner`", nativescript_runner:."`@nativescript/unit-test-runner`", valor:."`@valor/nativescript-websockets`"}' "$registry"
else
  echo "registry file not found"
fi

echo
echo "== references to generated registry / getDependencies =="
rg -n "test-deps-versions-generated|getDependencies|test-initialization-service|vitest|nativescript-websockets" . --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' | sed -n '1,220p'

Repository: NativeScript/nativescript-cli

Length of output: 15797


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== generate-test-deps.js outline and relevant contents =="
wc -l scripts/generate-test-deps.js
sed -n '1,240p' scripts/generate-test-deps.js

echo
echo "== test-initialization-service.ts relevant contents =="
sed -n '1,100p' lib/services/test-initialization-service.ts

echo
echo "== package-version script files =="
fd -a '(package|test)-deps|generate.*deps|deps.*version' scripts config lib test packages --glob '*.{js,ts,json}' | sed -n '1,120p'

Repository: NativeScript/nativescript-cli

Length of output: 3992


Run the generated dependency-version script for the new Vitest packages.

scripts/generate-test-deps.js reads config/test-dependencies.json and writes config/test-deps-versions-generated.json. The generated registry is missing now, so ns test init --framework vitest fails before package installation. Add config/test-deps-versions-generated.json or regenerate it.

🤖 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 `@config/test-dependencies.json` around lines 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.

{
"name": "@jsdevtools/coverage-istanbul-loader",
"frameworks": ["jasmine", "mocha", "qunit"]
},
{
"name": "karma",
"frameworks": ["jasmine", "mocha", "qunit"]
},
{
"name": "karma-coverage",
"frameworks": ["jasmine", "mocha", "qunit"]
},
{
"name": "karma-nativescript-launcher",
"frameworks": ["jasmine", "mocha", "qunit"]
},
{
"name": "mocha",
Expand Down Expand Up @@ -53,6 +78,7 @@
"projectType": ".ts"
},
{
"name": "nyc"
"name": "nyc",
"frameworks": ["jasmine", "mocha", "qunit"]
}
]
]
4 changes: 3 additions & 1 deletion docs/man_pages/project/testing/test-init.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ position: 21

Configures your project for unit testing with a selected framework. This operation installs the @nativescript/unit-test-runner npm module and its dependencies and creates a `tests` folder in the `app` directory.

The recommended framework is `vitest`, which runs your specs inside real NativeScript runtimes on device/emulator and also supports UI testing. The Karma-based frameworks (jasmine, mocha, qunit) are deprecated and will be removed in a future release.

### Commands

Usage | Synopsis
Expand All @@ -17,7 +19,7 @@ General | `$ ns test init [--framework <Framework>]`

### Options

* `--framework <Framework>` - Sets the unit testing framework to install. The following frameworks are available: mocha, jasmine and qunit.
* `--framework <Framework>` - Sets the unit testing framework to install. The following frameworks are available: vitest (recommended), mocha, jasmine and qunit (deprecated).

<% if(isHtml) { %>

Expand Down
4 changes: 4 additions & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ injector.requireCommand("deploy", "./commands/deploy");
injector.requireCommand("embed", "./commands/embedding/embed");

injector.require("testExecutionService", "./services/test-execution-service");
injector.require(
"vitestExecutionService",
"./services/vitest-execution-service",
);
injector.requireCommand("dev-test|android", "./commands/test");
injector.requireCommand("dev-test|ios", "./commands/test");
injector.requireCommand("test|android", "./commands/test");
Expand Down
Loading