Skip to content

The test android command fails to run tests #1636

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
vchimev opened this issue Mar 22, 2016 · 10 comments
Closed

The test android command fails to run tests #1636

vchimev opened this issue Mar 22, 2016 · 10 comments
Assignees
Milestone

Comments

@vchimev
Copy link

vchimev commented Mar 22, 2016

tns test android fails with _com.tns.NativeScriptException: Failed to find module: "./config", relative to: /app/tns_modules/nativescript-unit-test-runner_.

Steps to reproduce:

tns create appTest
cd appTest
tns test init
tns test android

package.json:

mcsofvchimev:appTest vchimev$ cat package.json 
{
  "nativescript": {
    "id": "org.nativescript.appTest",
    "tns-android": {
      "version": "1.7.0"
    }
  },
  "dependencies": {
    "nativescript-unit-test-runner": "^0.3.3",
    "tns-core-modules": "1.7.0"
  },
  "devDependencies": {
    "chai": "^3.5.0",
    "karma": "^0.13.22",
    "karma-chai": "^0.1.0",
    "karma-mocha": "^0.2.2",
    "karma-nativescript-launcher": "^0.4.0",
    "mocha": "^2.4.5"
  }
}

Output:

mcsofvchimev:appTest vchimev$ tns test android
Project successfully prepared
Executing after-prepare hook from /Users/vchimev/Work/release/appEmu/hooks/after-prepare/nativescript-unit-test-runner.js
22 03 2016 13:13:33.595:WARN [karma]: Port 9876 in use
22 03 2016 13:13:33.598:INFO [karma]: Karma v0.13.22 server started at http://localhost:9877/
22 03 2016 13:13:33.603:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Transferring project files...
Successfully transferred all project files.
Applying changes...
Successfully synced application org.nativescript.appEmu on device emulator-5554.
03-22 13:13:35.335  2752  2752 W System.err:    at com.tns.Platform.callJSMethodNative(Native Method)
03-22 13:13:35.335  2752  2752 W System.err:    at com.tns.Platform.dispatchCallJSMethodNative(Platform.java:816)
03-22 13:13:35.335  2752  2752 W System.err:    at com.tns.Platform.callJSMethod(Platform.java:715)
03-22 13:13:35.335  2752  2752 W System.err:    at com.tns.Platform.callJSMethod(Platform.java:694)
03-22 13:13:35.335  2752  2752 W System.err:    at com.tns.Platform.callJSMethod(Platform.java:684)
03-22 13:13:35.335  2752  2752 D TNS.JAVA.JsDebugger: Sending console message to inspector:{"seq":0,"type":"event","event":"messageAdded","success":true,"body":{"message":{"source":"console-api","type":"log","level":"error","line":0,"column":0,"url":"","groupLevel":7,"repeatCount":1,"text":"The application crashed because of an uncaught exception. You can look at \"stackTrace\" or \"nativeException\" for more detailed information about the exception.\njava.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.appEmu\/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to find module: \".\/config\", relative to: \/app\/tns_modules\/nativescript-unit-test-runner\/\n\tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)\n\tat android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)\n\tat android.app.ActivityThread.-wrap11(ActivityThread.java)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)\n\tat android.os.Handler.dispatchMessage(Handler.java:102)\n\tat android.os.Looper.loop(Looper.java:148)\n\tat android.app.ActivityThread.main(ActivityThread.java:5417)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\nCaused by: com.tns.NativeScriptException: Failed to find module: \".\/config\", relative to: \/app\/tns_modules\/nativescript-unit-test-runner\/\n\tat com.tns.Module.resolvePathHelper(Module.java:220)\n\tat com.tns.Module.resolvePath(Module.java:60)\n\tat com.tns.Platform.callJSMethodNative(Native Method)\n\tat com.tns.Platform.dispatchCallJSMethodNative(Platform.java:816)\n\tat com.tns.Platform.callJSMethod(Platform.java:715)\n\tat com.tns.Platform.callJSMethod(Platform.java:694)\n\tat com.tns.Platform.callJSMethod(Platform.java:684)\n\tat com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:14)\n\tat android.app.Activity.performCreate(Activity.java:6237)\n\tat android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)\n\tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)\n\t... 9 more\n"}}}

Workaround:
Rerun the tns test android command.

@Headcult
Copy link

Even I'm facing the same issue (on TNS 2.0). Any updates on this? Will there be a fix for this, if the root cause is known. Thank you.

@Jpaagt
Copy link

Jpaagt commented May 22, 2016

I have the same problem, version 2.0.0, here is a part of crash message on the device:

Unhandled Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{.../com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to find module: "./config", relative to: /app/tns_modules?nativescript-unit-test-runner/ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338) at ...

@BrunoDF
Copy link

BrunoDF commented Jun 3, 2016

+1

I also had the same problem:

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.borajogamobile/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to find module: "./config", relative to: /app/tns_modules/nativescript-unit-test-runner/ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257) at android.app.ActivityThread.access$800(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5097) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) Caused by: com.tns.NativeScriptException: Failed to find module: "./config", relative to: /app/tns_modules/nativescript-unit-test-runner/ at com.tns.Module.resolvePathHelper(Module.java:220) at com.tns.Module.resolvePath(Module.java:60) at com.tns.Runtime.callJSMethodNative(Native Method) at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861) at com.tns.Runtime.callJSMethodImpl(Runtime.java:726) at com.tns.Runtime.callJSMethod(Runtime.java:712) at com.tns.Runtime.callJSMethod(Runtime.java:693) at com.tns.Runtime.callJSMethod(Runtime.java:683) at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:13) at android.app.Activity.performCreate(Activity.java:5248) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162) ... 11 more

@circy
Copy link

circy commented Jun 3, 2016

+1

I have the same problem.

C:\Projects\tmm-MobileApp>tns test android --emulator --justlaunch
Executing before-prepare hook from C:\Projects\tmm-MobileApp\hooks\before-prepare\nativescript-dev-typescript.js
Found peer TypeScript 1.8.10
Project successfully prepared
Executing after-prepare hook from C:\Projects\tmm-MobileApp\hooks\after-prepare\nativescript-unit-test-runner.js
03 06 2016 14:58:45.276:WARN [watcher]: Pattern "C:/Projects/tmm-MobileApp/app/*/*.spec.ts" does not match any file.
03 06 2016 14:58:45.293:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
03 06 2016 14:58:45.301:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Transferring project files...
Successfully transferred all project files.
Applying changes...
Successfully synced application org.nativescript.travelMizeMe on device emulator-5554.

unbenannt

@vchimev
Copy link
Author

vchimev commented Jun 6, 2016

@Headcult @Jpaagt @BrunoDF @circy

Guys,

do you experience this problem with NativeScript CLI version 2.0.1? If yes, does the workaround (rerun the tns test android command) help?

I am unable to replicate the issue with {N} CLI 2.0.1 at my end.

@BrunoDF
Copy link

BrunoDF commented Jun 7, 2016

@vchimev

I'm in version 2.0.1 and still have the problem.

The workaround works though.

@circy
Copy link

circy commented Jun 7, 2016

@vchimev

The same as for @BrunoDF

@vchimev vchimev self-assigned this Jun 9, 2016
@vchimev
Copy link
Author

vchimev commented Jun 16, 2016

Thanks, guys!

Hey @rosen-vladimirov, @hdeshev, @vakrilov,

do you have any idea about this issue? I still reproduce it rarely with our master branches, in particular:

CLI - 2.1.0-734
nativescript-unit-test-runner - 0.3.3

@nikhiljha
Copy link

Yup, same problem.

Workaround gives some error about tns-karma.

@rosen-vladimirov rosen-vladimirov added this to the 2.3.0 milestone Aug 30, 2016
rosen-vladimirov added a commit that referenced this issue Aug 30, 2016
First call to `tns test <platform>` always fails as the file with Karma configuration is not sent to device. The reason is that it's craeted in `node_modules/unit-test-runner` after the project is prepared.
The second execution of the command will include the file, but it may not be correct. It's regenerated, but again after the project is prepared.
Fix the `test-execution-service` to prepare the project after the configuration file is created.
Fixes #1636 and possibly #2016
Fixes the problem in Travis builds that console hangs and travis builds never end.
@rosen-vladimirov
Copy link
Contributor

rosen-vladimirov commented Aug 30, 2016

Steps to reproduce:

  1. $ tns create app1
  2. $ cd app1
  3. $ tns test init
  4. $ rm -rf node_modules platforms
  5. $ tns test android
    Make sure that you do not have node_modules and platforms directories before calling tns test android. Check related PR for more details :)

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

8 participants