Skip to content

Unable to run tns test <platform> #4071

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

Closed
dcarrot2 opened this issue Oct 26, 2018 · 2 comments
Closed

Unable to run tns test <platform> #4071

dcarrot2 opened this issue Oct 26, 2018 · 2 comments
Assignees
Milestone

Comments

@dcarrot2
Copy link

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.0.0-2018-10-25-12514
  • Cross-platform modules: 4.2.1
  • Android Runtime: 4.2.0
  • iOS Runtime: 4.2.0
  • Plugin(s):
"dependencies": {
        "@angular/animations": "~6.1.0",
        "@angular/common": "~6.1.0",
        "@angular/compiler": "~6.1.0",
        "@angular/core": "~6.1.0",
        "@angular/forms": "~6.1.0",
        "@angular/http": "~6.1.0",
        "@angular/platform-browser": "~6.1.0",
        "@angular/platform-browser-dynamic": "~6.1.0",
        "@angular/router": "~6.1.0",
        "nativescript-angular": "~6.1.0",
        "nativescript-theme-core": "~1.0.4",
        "nativescript-unit-test-runner": "^0.3.4",
        "reflect-metadata": "~0.1.8",
        "rxjs": "~6.2.0",
        "tns-core-modules": "~4.2.0",
        "zone.js": "^0.8.26"
    },
    "devDependencies": {
        "@nativescript/schematics": "~0.3.0",
        "chai": "4.2.0",
        "karma": "3.1.1",
        "karma-chai": "0.1.0",
        "karma-mocha": "1.3.0",
        "karma-nativescript-launcher": "0.4.0",
        "mocha": "5.2.0",
        "nativescript-dev-typescript": "~0.7.0",
        "typescript": "~2.7.2"
    }

Describe the bug
tns test android and tns test ios fails to complete due to socket timeout and transport error, respectively.

On iOS:

 $ tns test ios
Searching for devices...
26 10 2018 09:02:40.485:WARN [watcher]: Pattern "/Users/ddiaz/workspace/tns-test-plat/app/**/*.js" does not match any file.
26 10 2018 09:02:40.496:WARN [karma]: No captured browser, open http://localhost:9876/
26 10 2018 09:02:40.499:INFO [karma-server]: Karma v3.1.1 server started at http://0.0.0.0:9876/
26 10 2018 09:02:40.499:INFO [launcher]: Launching browsers ios with concurrency unlimited
26 10 2018 09:02:40.509:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Executing before-prepare hook from /Users/ddiaz/workspace/tns-test-plat/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.7.2
Preparing project...
Project successfully prepared (ios)
Executing after-prepare hook from /Users/ddiaz/workspace/tns-test-plat/hooks/after-prepare/nativescript-unit-test-runner.js
Executing before-liveSync hook from /Users/ddiaz/workspace/tns-test-plat/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-watchPatterns hook from /Users/ddiaz/workspace/tns-test-plat/hooks/before-watchPatterns/nativescript-dev-typescript.js
Executing before-watch hook from /Users/ddiaz/workspace/tns-test-plat/hooks/before-watch/nativescript-dev-typescript.js
Found peer TypeScript 2.7.2
Skipping prepare.
Successfully transferred all files on device 980CDF63-0DE2-4904-B01D-D92EAAE03791.
Refreshing application on device 980CDF63-0DE2-4904-B01D-D92EAAE03791...
Successfully synced application org.nativescript.tnstestplat on device 980CDF63-0DE2-4904-B01D-D92EAAE03791.
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:54:28: NSUTR: fetching http://127.0.0.1:9876/context.json
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:54:28: NSUTR: fetching http://10.27.38.116:9876/context.json
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:60:32: NSUTR: found karma at 127.0.0.1
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:97:20: NSUTR: connecting to karma at http://127.0.0.1:9876
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:60:32: NSUTR: found karma at 10.27.38.116
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:116:24: NSUTR: successfully connected to karma
26 10 2018 09:03:00.171:INFO [NativeScript / 12.0 (12.0; iPhone)]: Connected on socket mFoKgG3ZXp0X-KXFAAAA with id NativeScriptUnit-8860
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:159:20: NSUTR: downloading http://127.0.0.1:9876/context.json
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:200:32: NSUTR: eval script /base/node_modules/chai/chai.js?db92883971379fbea71a12c25b271c26a3afc3f6
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:200:32: NSUTR: eval script /base/node_modules/karma-chai/adapter.js?bab484a2111791847997ed88414622bccfbd2749
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:200:32: NSUTR: eval script /base/node_modules/mocha/mocha.js?840d4fbbcc65a16cec39f9e25af2ea6d2cff68ea
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:200:32: NSUTR: eval script /base/node_modules/karma-mocha/lib/adapter.js?e8826109cf50b958ee4bd667517729ffdd4de363
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:212:24: NSUTR: beginning test run
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:254:20: NSUTR: completed test run.
NativeScript / 12.0 (12.0; iPhone): Executed 0 of 0 ERROR (0.003 secs / 0 secs)
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:258:24: NSUTR: completeAck
NativeScript / 12.0 (12.0; iPhone) ERROR
  DisconnectedClient disconnected from CONNECTED state (transport error)
NativeScript / 12.0 (12.0; iPhone): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

On Android:

 $ tns test android
Searching for devices...
Starting Android emulator with image Pixel_API_28
Waiting for emulator device initialization...
26 10 2018 09:31:46.069:WARN [watcher]: Pattern "/Users/ddiaz/workspace/tns-test-plat/app/**/*.js" does not match any file.
26 10 2018 09:31:46.080:WARN [karma]: No captured browser, open http://localhost:9876/
26 10 2018 09:31:46.083:INFO [karma-server]: Karma v3.1.1 server started at http://0.0.0.0:9876/
26 10 2018 09:31:46.083:INFO [launcher]: Launching browsers android with concurrency unlimited
26 10 2018 09:31:46.091:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Executing before-prepare hook from /Users/ddiaz/workspace/tns-test-plat/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.7.2
Preparing project...
Successfully prepared plugin nativescript-angular for android.
Successfully prepared plugin nativescript-theme-core for android.
Successfully prepared plugin nativescript-unit-test-runner for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin nativescript-intl for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Project successfully prepared (android)
Executing after-prepare hook from /Users/ddiaz/workspace/tns-test-plat/hooks/after-prepare/nativescript-unit-test-runner.js
Executing before-liveSync hook from /Users/ddiaz/workspace/tns-test-plat/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-watchPatterns hook from /Users/ddiaz/workspace/tns-test-plat/hooks/before-watchPatterns/nativescript-dev-typescript.js
Executing before-watch hook from /Users/ddiaz/workspace/tns-test-plat/hooks/before-watch/nativescript-dev-typescript.js
Found peer TypeScript 2.7.2
Skipping prepare.
Building project...
Gradle build...
         + setting applicationId
         + applying user-defined configuration from /Users/ddiaz/workspace/tns-test-plat/App_Resources/Android/app.gradle
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: /Users/ddiaz/workspace/tns-test-plat/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Project successfully built.
Installing on device emulator-5554...
Successfully installed on device with identifier 'emulator-5554'.
Unable to apply changes on device: emulator-5554. Error is: Socket connection timed out..
Executing after-watch hook from /Users/ddiaz/workspace/tns-test-plat/hooks/after-watch/nativescript-dev-typescript.js

To Reproduce

Reproducible by creating a new project from template, and bootstrapping testing features.

npm un -g nativescript; npm i -g nativescript@rc
tns create test-proj --ng
tns test init
select Mocha
tns test ios --emulator

Expected behavior
Should run sample test successfully.

Sample project
Not attaching since it's reproducible from a newly created project--happy to do so if needed.

Additional context

@Fatme Fatme self-assigned this Oct 29, 2018
@Fatme
Copy link
Contributor

Fatme commented Oct 29, 2018

Hi @dcarrot2,

It seems your test files are not executed by unit test runner. Currently tns test command always looking for test files under the app folder. If your test files are located in another location (this can happen when the project has .nsconfig file), unit test runner is not able to execute them.

We're working on fixing and improving this behavior.

I'm not sure if this will be enough to run the tests successfully but I can suggest you to modify your karma.config file. You need to change the following:

files: ["src/tests/**/*.*"]

Let me know if this works on your side.

@dcarrot2
Copy link
Author

Yep, that did the trick, thanks! Only thing I notice is this still shows

NativeScript / 12.0 (12.0; iPhone) ERROR
  DisconnectedClient disconnected from CONNECTED state (transport error)
NativeScript / 12.0 (12.0; iPhone): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

after successfully running the tests. Just mentioning this as I'm not sure if it's intended behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants