Skip to content

Issue: Not able to run unit tests for nativescript-angular #1051

Open
@lambourn

Description

@lambourn

I am not able to run the unit tests inside the tests folder. Here is what I did:

Steps

  1. Cloned the nativescript-angular repo
  2. cd to tests folder
  3. tns platform add android
  4. tns test android (ran it on an emulator btw.)

Result

  • Test runner application starts on emulator
  • 95 tests get collected
  • 10 test cases get executed, then the runner crashes

Error points to zone-nativescript.js. Here is the relevant stack trace from console:

JS: !!! ngAfterViewInit -> loader: [object Object]
  DetachedLoader
    ✔ creates component
JS: !!! ngAfterViewInit -> loader: [object Object]
    ✔ creates component when ChangeDetectionStrategy is OnPush
  NsHttpBackEnd
    ✔ should work with local files prefixed with '~'
    ✔ should return 404 for non-existing local files prefixed with '~'
    ✔ should fallback to XHR backend when requesting remote files
  Http
    ✔ should work with local files prefixed with '~'
    ✔ request method should work with local files prefixed with '~'
    ✔ request method using Request type should work with local files prefixed with '~'
    ✔ should work with local files prefixed with '/'
    ✔ should work with remote files
23 10 2017 13:29:35.378:WARN [NativeScript / 25 (7.1.1; Android SDK built for x86_64)]: Disconnected (1 times)

Finished in 4.67 secs / 0.337 secs

JS: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
JS: NSUTR-socket.io: transport error
JS: NSUTR-socket.io: 1
System.err: com.tns.NativeScriptException:
System.err: Calling js method run failed
System.err:
System.err: ReferenceError: document is not defined
System.err: File: "file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js, line: 142, column: 24
System.err:
System.err: StackTrace:
System.err:     Frame: function:'JSONPPolling.doPoll', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 3140, column: 16
System.err:     Frame: function:'Polling.poll', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 3795, column: 8
System.err:     Frame: function:'Polling.doOpen', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 3739, column: 8
System.err:     Frame: function:'Transport.open', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 2882, column: 10
System.err:     Frame: function:'Socket.open', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 2303, column: 13
System.err:     Frame: function:'Socket', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 2184, column: 8
System.err:     Frame: function:'Socket', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 2110, column: 41
System.err:     Frame: function:'Manager.open.Manager.connect', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 309, column: 17
System.err:     Frame: function:'', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-unit-test-runner/socket.io.js', line: 619, column: 12
System.err:     Frame: function:'ZoneDelegate.invokeTask', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 398, column: 31
System.err:     Frame: function:'Zone.runTask', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 165, column: 47
System.err:     Frame: function:'ZoneTask.invoke', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 460, column: 38
System.err:     Frame: function:'timer', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 1634, column: 29
System.err:     Frame: function:'invoke', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/tns-core-modules/timer/timer.js', line: 19, column: 48
System.err:     Frame: function:'ZoneDelegate.invoke', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 365, column: 26
System.err:     Frame: function:'Zone.runGuarded', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 138, column: 47
System.err:     Frame: function:'', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 116, column: 29
System.err:     Frame: function:'run', file:'file:///data/data/org.nativescript.ngtests/files/app/tns_modules/tns-core-modules/timer/timer.js', line: 23, column: 13
System.err:
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:912)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:896)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:888)
System.err:     at com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
System.err:     at android.os.Handler.handleCallback(Handler.java:751)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
System.err:     at android.os.Looper.loop(Looper.java:154)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
ActivityManager: Process org.nativescript.ngtests (pid 5102) has died
ActivityManager: cleanUpApplicationRecord -- 5102

tns info output

┌──────────────────┬────────────────────┬────────────────┬──────────────────┐
│ Component        │ Current version    │ Latest version │ Information      │
│ nativescript     │ 3.2.1              │ 3.2.1          │ Up to date       │
│ tns-core-modules │ 3.3.0-2017-10-20-5 │ 3.2.0          │ Up to date       │
│ tns-android      │ 3.1.0              │ 3.2.0          │ Update available │
│ tns-ios          │ 3.1.0              │ 3.2.0          │ Update available │
└──────────────────┴────────────────────┴────────────────┴──────────────────┘

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions