question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unit testing for freshly created angular project is broken on android simulator

See original GitHub issue

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’ ],

android simulator: Nexus_S_API_28

Describe the bug unit testing for freshly created angular project is broken on android

To Reproduce run commands

$ tns create demo-mocha-tests-ng --ng
$ tns test init

select mocha

$ tns test android

screen shot 2018-12-13 at 12 41 55 pm

after running test application run is failed $ tns run android see screenshot above app can be run only after command $ tns platform clean android

Expected behavior example test should run on android

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ochemeryscommented, Dec 13, 2018

Thank you. When I added suggested line to App_Resources/Android/src/main/AndroidManifest.xml I was able to run example test but when I created a simple typescript test:

import { AppComponent } from '../app/app.component';

// application test
describe('Import Statement', function () {
		it('should be possible to add import statement', function () {
			const app = new AppComponent();
			chai.assert.equal(true, true);
		});
});

the run fails

13 12 2018 15:06:36.794: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)  /base/src/tests/example.spec.js?a737542566db4d779d1ad05914405977fcfa4f81 at line 0 FAILED
        ReferenceError: exports is not defined
NativeScript / 28 (9; Android SDK built for x86): Executed 1 of null (1 FAILED) ERROR (0.051 secs / 0 secs)
JS: NSUTR: completeAck
13 12 2018 15:06:37.427:WARN [NativeScript / 28 (9; Android SDK built for x86)]: Disconnected (0 times)Client disconnected from CONNECTED state (transporNativeScript / 28 (9; Android SDK built for x86) ERROR
  DisconnectedClient disconnected from CONNECTED state (transport error)
NativeScript / 28 (9; Android SDK built for x86): Executed 1 of null (1 FAILED) ERROR (0.051 secs / 0 secs)
0reactions
dtopuzovcommented, Jan 31, 2019

I see two issues reported above:

  1. Unit testing do not work on new NG projects (because nsconfig is not respected)
  2. tns run after tns test require platform clean

Issue #1 is fixed in nativescript-unit-test-runner@0.4.1 and nativescript@next (will be shipped in 5.2.0).

Issue #2 is duplicate of https://github.com/NativeScript/nativescript-cli/issues/3146#issuecomment-457686993

Read more comments on GitHub >

github_iconTop Results From Across the Web

unit testing for freshly created angular project is broken on android ...
Coming soon: A brand new website interface for an even better experience!
Read more >
How can I Fix Default Unit Tests Failing on a Working Project
I'm using the original test cases that are provided when you build a project with the cli. Karma output: AppComponent should create the...
Read more >
Unit Testing - NativeScript Docs
Write and execute unit tests to ensure that newly added features are working correctly and no regressions are introduced in the mobile app....
Read more >
How to perform Unit testing for Angular apps? | BrowserStack
Step by Step tutorial to perform Unit Testing for Angular Apps using Jasmine and Karma. Learn to create, write and run unit tests...
Read more >
Angular Testing With Jasmine And Karma Using Selenium ...
Good Unit testing can even serve as project documentation. Developers, especially those who newly joined the team, can look at the unit tests...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found