NativeScript / NativeScript/nativescript-cli

ns 9 running test after running the app starts the app not the test runner.

未关闭
#6,015 0 条评论 1 个 reaction 已指派 1 人 在 GitHub 查看

@NathanWalker 已经在做这个了。

开始于 2026年5月1日。

in progress
主要语言
JavaScript
星标
1.1k
派生
204
平均合并
1 天 9 小时
30 天内合并 PR
8

描述

Issue Description

When I create a new NativeScript 9 Angular App using ns create and I add tests using ns test init then I run the app using (e.g.) ns run android, stop it and run the tests with (e.g.) ns test android the App is launched on my emulator instead of the test runner.

The issue happens on both Android and iOS. The tests run correctly if a clean is run before them.

The issue also happens on a NativeScript Angular App upgraded from 8 to 9, which worked correctly before the upgrade to 9.

The issue is reproduced with an Angular App that uses Jasmine as its test framework, it does not appear that test framework should make a difference but other test frameworks have not been checked.

There are historical issues with this happening on NativeScript apps before version 9. I have checked for the issues that caused this in the past and none of the fixes or work arounds apply as far as I can tell.

Reproduction
  1. Install or update to NativeScript 9. I was using 9.0.6 CLI, but I have also seen the problem on older versions of 9.
  2. Create a new NativeScript App with:

ns create myNewNSAngularApp

  1. Choose Angular as the Framework and "HelloWorld" as the example you want to use.
  2. Once created cd into the app cd myNewNSAngularApp
  3. Add tests with:

ns test init --framework jasmine

  1. Once created, prepare, in my case for android, with:

ns prepare android

  1. Run the app with:

ns run android

  1. After checking the app runs, terminate it on the emulator and in the console.
  2. Run the tests with:

ns test android

  1. Notice that instead of the test running, the app has restarted.
  2. Clean with:

ns clean

  1. Run the tests again with:

ns test android

  1. Note that the test runs as expected.
Relevant log output (if applicable)

Environment
OS: Windows 11 10.0.26200
CPU: (22) x64 Intel(R) Core(TM) Ultra 7 155H
Shell: Not Found
node: 20.19.6
npm: 10.8.2
nativescript: Not Found

# android
java: 17.0.18
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: Not Found
cocoapods: Not Found
python: Not Found
python3: Not Found
ruby: Not Found
platforms: Not Found
Dependencies
"dependencies": {
  "@angular/animations": "~20.2.0",
  "@angular/common": "~20.2.0",
  "@angular/compiler": "~20.2.0",
  "@angular/core": "~20.2.0",
  "@angular/forms": "~20.2.0",
  "@angular/platform-browser": "~20.2.0",
  "@angular/platform-browser-dynamic": "~20.2.0",
  "@angular/router": "~20.2.0",
  "@nativescript/angular": "^20.0.0",
  "@nativescript/core": "~9.0.0",
  "@nativescript/unit-test-runner": "^4.0.1",
  "rxjs": "~7.8.0",
  "zone.js": "~0.15.0"
},
"devDependencies": {
  "@angular-devkit/build-angular": "~20.2.0",
  "@angular/compiler-cli": "~20.2.0",
  "@jsdevtools/coverage-istanbul-loader": "3.0.5",
  "@nativescript/android": "9.0.4",
  "@nativescript/tailwind": "^2.1.0",
  "@nativescript/types": "~9.0.0",
  "@nativescript/webpack": "~5.0.25",
  "@ngtools/webpack": "~20.2.0",
  "@types/jasmine": "6.0.0",
  "karma": "6.4.4",
  "karma-coverage": "2.2.1",
  "karma-jasmine": "4.0.2",
  "karma-nativescript-launcher": "1.0.0",
  "nyc": "18.0.0",
  "tailwindcss": "~3.4.0",
  "typescript": "~5.8.0"
}
Please accept these terms

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。