Skip to content

unit testing for freshly created angular project is broken when import a package from node_modules #4244

Closed
@ochemerys

Description

@ochemerys

Environment
$ tns doctor
✔ Getting environment information

No issues were detected.
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Xcode is installed and is configured properly.
✔ xcodeproj is installed and is configured properly.
✔ CocoaPods are installed.
✔ CocoaPods update is not required.
✔ CocoaPods are configured properly.
✔ Your current CocoaPods version is newer than 1.0.0.
✔ Python installed and configured correctly.
✔ The Python 'six' package is found.
✔ Xcode version 10.1.0 satisfies minimum required version 9.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 5.1.0 version and is up to date.
✔ Component tns-core-modules has 5.1.0 version and is up to date.
✔ Component tns-android has 5.1.0 version and is up to date.
✔ Component tns-ios has 5.1.0 version and is up to date.

karma.conf.js contains
// list of files / patterns to load in the browser
files: [
'src/tests/**/*.js'
],

the same issue on iOS and Android devices

Describe the bug
unit testing for freshly created angular project is broken when import a package from node_modules

To Reproduce
I followed steps for workarounds provided in #4232
then I added
import { expect } from 'chai';
my test fails with error message:

5 12 2018 15:02:23.006:WARN [NativeScript / 28 (9; Android SDK built for x86)]: Adapter did not report total number of specs.
NativeScript / 28 (9; Android SDK built for x86) ../../tests/example.spec.js at line 0 FAILED
Error: com.tns.NativeScriptException: Failed to find module: "chai", relative to: app/tns_modules/
com.tns.Module.resolvePathHelper(Module.java:146)
com.tns.Module.resolvePath(Module.java:55)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)
com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)
com.tns.Runtime.callJSMethod(Runtime.java:987)
com.tns.Runtime.callJSMethod(Runtime.java:967)
com.tns.Runtime.callJSMethod(Runtime.java:959)
com.tns.gen.java.lang.Runnable.run(Runnable.java:15)
android.os.Handler.handleCallback(Handler.java:873)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:193)
android.app.ActivityThread.main(ActivityThread.java:6669)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
NativeScript / 28 (9; Android SDK built for x86): Executed 1 of null (1 FAILED) ERROR (0.056 secs / 0 secs)
Test run failed.

it looks like test runner is not able to find installed chai npm package

I commented out "chai" and tried "sinon" instead.
The same result

Expected behavior
I should be able to use import statements for node packages

Is there any workaround for this one?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions