Skip to content
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

Unit test runner do not work in --watch mode (it is default mode now) #2739

Closed
dtopuzov opened this issue Apr 25, 2017 · 7 comments
Closed

Comments

@dtopuzov
Copy link
Contributor

From @hettiger on April 23, 2017 8:38

Hello,

I'm currently having a look at {NS} testing capabilities. Using the RC this doesn't seem to be stable yet? Here's what I'm talking about:

Refreshing application...
No matching processes belonging to you were found
23 04 2017 10:29:50.348:WARN [NativeScript / 10.3 (10.3; iPhone)]: Disconnected (1 times)
NativeScript / 10.3 (10.3; iPhone) ERROR
  Disconnectedundefined
23 04 2017 10:06:43.983:WARN [NativeScript / 24 (7.0; Android SDK built for x86)]: Disconnected (1 times)
NativeScript / 24 (7.0; Android SDK built for x86) ERROR
  Disconnectedundefined

I think there shouldn't be errors on a clean project or is that to be expected?

This is the basic installation process for my dummy app:

npm install -g nativescript@rc
tns create "NativeScript-Mocha" --appid "com.hettiger.demo" --template tns-template-hello-world-ts@rc
tns test init
npm install --save-dev mocha
npm install --save-dev chai

tns test android --emulator

tns test ios --emulator

Android Output

tns test android --emulator

/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run test-android --scripts-prepend-node-path

> @ test-android /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha
> tns test android --emulator

Searching for devices...
Starting Android emulator with image Nexus_5X_API_24_x86
Waiting for emulator device initialization....
23 04 2017 10:06:36.167:WARN [karma]: No captured browser, open http://localhost:9876/
23 04 2017 10:06:36.177:INFO [karma]: Karma v1.6.0 server started at http://0.0.0.0:9876/
23 04 2017 10:06:36.177:INFO [launcher]: Launching browser android with unlimited concurrency
23 04 2017 10:06:36.200:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Executing before-prepare hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.2.2
Preparing project...
23 04 2017 10:06:37.870:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/app.js".
23 04 2017 10:06:37.871:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/main-page.js".
23 04 2017 10:06:37.872:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/main-view-model.js".
23 04 2017 10:06:37.873:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/bundle-config.js".
23 04 2017 10:06:38.124:WARN [karma]: No captured browser, open http://localhost:9876/
Project successfully prepared (android)
Executing after-prepare hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/after-prepare/nativescript-dev-android-snapshot.js
Executing after-prepare hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/after-prepare/nativescript-unit-test-runner.js
Skipping prepare.
Skipping package build. No changes detected on the native side. This will be fast!
Skipping install.
Transferring project files...
Successfully transferred all files.
Refreshing application...
Successfully synced application com.hettiger.demo on device emulator-5554.

Executing before-watch hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/before-watch/nativescript-dev-typescript.js
Found peer TypeScript 2.2.2
JS: NSUTR: fetching http://127.0.0.1:9876/context.json
JS: NSUTR: fetching http://192.168.1.2:9876/context.json
JS: NSUTR: found karma at 192.168.1.2
JS: NSUTR: connecting to karma at http://192.168.1.2:9876
JS: NSUTR: successfully connected to karma
23 04 2017 10:06:41.040:INFO [NativeScript / 24 (7.0; Android SDK built for x86)]: Connected on socket HCco3raWQq2y2Z9QAAAA with id NativeScriptUnit-8895
10:06:41 AM - Compilation complete. Watching for file changes.



23 04 2017 10:06:41.082:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/bundle-config.js".
23 04 2017 10:06:41.084:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/app.js".
23 04 2017 10:06:41.084:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/main-page.js".
23 04 2017 10:06:41.086:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/main-view-model.js".
JS: NSUTR: downloading http://192.168.1.2:9876/context.json
JS: NSUTR: eval script /base/node_modules/chai/chai.js?ab7cf506d9d77c111c878b1e10b7f25348630760
JS: NSUTR: eval script /base/node_modules/karma-chai/adapter.js?bab484a2111791847997ed88414622bccfbd2749
JS: NSUTR: eval script /base/node_modules/mocha/mocha.js?0491afff0b566ea45cd04c9164a355dba705689e
23 04 2017 10:06:41.337:INFO [karma]: Delaying execution, these browsers are not ready: NativeScript / 24 (7.0; Android SDK built for x86)
JS: NSUTR: eval script /base/node_modules/karma-mocha/lib/adapter.js?e8826109cf50b958ee4bd667517729ffdd4de363
JS: NSUTR: require script /base/app/tests/example.js?4d4b898e3e2ebaeb3a0c54cf47ad315f18439403 from ../../tests/example.js
JS: NSUTR: beginning test run
JS: NSUTR: completed test run.
NativeScript / 24 (7.0; Android SDK built for x86): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
NativeScript / 24 (7.0; Android SDK built for x86): Executed 1 of 1 SUCCESS (0 secs / 0.003 secs)
NativeScript / 24 (7.0; Android SDK built for x86): Executed 1 of 1 SUCCESS (0.044 secs / 0.003 secs)
JS: NSUTR: completeAck
JS: NSUTR: disregarding second execution
23 04 2017 10:06:43.983:WARN [NativeScript / 24 (7.0; Android SDK built for x86)]: Disconnected (1 times)
NativeScript / 24 (7.0; Android SDK built for x86) ERROR
  Disconnectedundefined

iOS Output

tns test ios --emulator

/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run test-ios --scripts-prepend-node-path

> @ test-ios /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha
> tns test ios --emulator

Searching for devices...
23 04 2017 10:29:34.860:WARN [karma]: No captured browser, open http://localhost:9876/
23 04 2017 10:29:34.871:INFO [karma]: Karma v1.6.0 server started at http://0.0.0.0:9876/
23 04 2017 10:29:34.871:INFO [launcher]: Launching browser ios with unlimited concurrency
23 04 2017 10:29:34.881:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Executing before-prepare hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.2.2
Preparing project...
23 04 2017 10:29:36.936:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/bundle-config.js".
23 04 2017 10:29:36.938:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/app.js".
23 04 2017 10:29:36.941:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/main-page.js".
23 04 2017 10:29:36.941:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/main-view-model.js".
23 04 2017 10:29:37.192:WARN [karma]: No captured browser, open http://localhost:9876/
Project successfully prepared (ios)
Executing after-prepare hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/after-prepare/nativescript-dev-android-snapshot.js
Executing after-prepare hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/after-prepare/nativescript-unit-test-runner.js
Skipping prepare.
Skipping package build. No changes detected on the native side. This will be fast!
Skipping install.
Transferring project files...
Successfully transferred all files.
Refreshing application...
No matching processes belonging to you were found
Successfully synced application com.hettiger.demo on device DA931253-F078-4921-A4CE-4D5339765011.

Executing before-watch hook from /Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/hooks/before-watch/nativescript-dev-typescript.js
Found peer TypeScript 2.2.2
objc[4753]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x122a07cc0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x12281e6f0). One of the two will be used. Which one is undefined.
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://192.168.1.2: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 192.168.1.2
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:116:24: NSUTR: successfully connected to karma
23 04 2017 10:29:47.163:INFO [NativeScript / 10.3 (10.3; iPhone)]: Connected on socket D9-JE_euthE4qYcmAAAA with id NativeScriptUnit-3668
23 04 2017 10:29:47.618:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/bundle-config.js".
23 04 2017 10:29:47.619:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/app.js".
10:29:47 AM - Compilation complete. Watching for file changes.



23 04 2017 10:29:47.620:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/main-page.js".
23 04 2017 10:29:47.622:INFO [watcher]: Changed file "/Users/martin/Documents/Projekte/2017-04__NativeScript-Mocha/NativeScript-Mocha/app/main-view-model.js".
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?ab7cf506d9d77c111c878b1e10b7f25348630760
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?0491afff0b566ea45cd04c9164a355dba705689e
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:196:32: NSUTR: require script /base/app/tests/example.js?4d4b898e3e2ebaeb3a0c54cf47ad315f18439403 from ../../tests/example.js
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:212:24: NSUTR: beginning test run
NativeScript / 10.3 (10.3; iPhone): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:254:20: NSUTR: completed test run.
NativeScript / 10.3 (10.3; iPhone): Executed 1 of 1 SUCCESS (0 secs / 0 secs)
NativeScript / 10.3 (10.3; iPhone): Executed 1 of 1 SUCCESS (0.007 secs / 0 secs)
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:258:24: NSUTR: completeAck
23 04 2017 10:29:50.348:WARN [NativeScript / 10.3 (10.3; iPhone)]: Disconnected (1 times)
NativeScript / 10.3 (10.3; iPhone) ERROR
  Disconnectedundefined

Package

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "com.hettiger.demo",
    "tns-ios": {
      "version": "3.0.0-rc.1-2017-3-28-2"
    },
    "tns-android": {
      "version": "2.5.0"
    }
  },
  "scripts": {
    "reset": "tns platform remove android || true && tns platform remove ios || true",
    "run-android": "tns run ios --no-watch",
    "run-ios": "tns run ios --no-watch",
    "test-android": "tns test android --emulator",
    "test-ios": "tns test ios --emulator"
  },
  "dependencies": {
    "nativescript-theme-core": "~1.0.2",
    "nativescript-unit-test-runner": "^0.3.4",
    "tns-core-modules": "rc"
  },
  "devDependencies": {
    "babel-traverse": "6.24.1",
    "babel-types": "6.24.1",
    "babylon": "6.17.0",
    "chai": "^3.5.0",
    "karma": "^1.6.0",
    "karma-chai": "^0.1.0",
    "karma-mocha": "^1.3.0",
    "karma-nativescript-launcher": "^0.4.0",
    "lazy": "1.0.11",
    "mocha": "^3.2.0",
    "nativescript-dev-android-snapshot": "^0.*.*",
    "nativescript-dev-typescript": "~0.4.0",
    "typescript": "~2.2.1"
  }
}

Copied from original issue: NativeScript/nativescript-cli-tests#61

@pkoleva pkoleva added the bug label May 3, 2017
@dtopuzov dtopuzov changed the title Testing not working with {NS}@rc yet? Unit test runner crash after execute May 4, 2017
@dtopuzov
Copy link
Contributor Author

dtopuzov commented May 4, 2017

@hettiger this happens because unit test runner crash after execute in watch mode (which is the default one)

You should not see this message when run tns test android --no-watch or tns test android --justlaunch.

@ishitatsuyuki
Copy link

@dtopuzov By the way, this is not crash but just intended exit due to livesync unimplemented. This is not bug but an essential feature missing.

@hettiger
Copy link

hettiger commented May 4, 2017

Makes sense but that's not really straight forward. It's up to you guys if you want to close this issue or not. I think there should be a better error message, --no-watch should be default or the livesync should get implemented.

@dtopuzov dtopuzov changed the title Unit test runner crash after execute Unit test runner do not work in --watch mode (and --watch is default now) May 4, 2017
@dtopuzov dtopuzov changed the title Unit test runner do not work in --watch mode (and --watch is default now) Unit test runner do not work in --watch mode (it is default mode now) May 4, 2017
@hauthorn
Copy link

hauthorn commented Jul 3, 2017

Newcomers question: So there is no livesync for running tests in nativescript 3?
This is something to mention in the docs. It's really a pain to work without.

@ishitatsuyuki
Copy link

It can watch, but it restarts the test runner every time.

@pkoleva pkoleva removed the bug label Jul 11, 2017
@simonox
Copy link

simonox commented Nov 8, 2017

After the test runner ist restarted, it only says "No known hosts" and does not re-run the unit tests.

@Fatme
Copy link
Contributor

Fatme commented Jul 18, 2019

Hey guys,

We've improved a lot our testing story as fixed a bunch of issues and integrated it with webpack workflow. tns test command is working now in watch mode as it still restarts the application on every change. The NativeScript / 24 (7.0; Android SDK built for x86)]: Disconnected (1 times) message is still shown due to some limitations of karma server.

I'm closing this issue, feel free to open an another in case you face problems.

@Fatme Fatme closed this as completed Jul 18, 2019
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

9 participants