Dilanka Rathnayake
Dilanka Rathnayake

Reputation: 662

Jasmine Karma Unit testing doesn't detect my test cases in Angular2 Unit testing

I faced to a wired problem while unit testing my angular2/ionic2 application. I wrote some unit tests to the application and they were tested normally when I hit npm test. But today when I hit npm test it doesn't detect any unit test of my project. It gives the following output in the terminal.

dilanka@Dilanka-NoteBook:/media/dilanka/Stuff/CODE BASE/Inspection/UnitTesting/Inspection-Rewrite$ npm test

> ionic-hello-world@ test /media/dilanka/Stuff/CODE BASE/Inspection/UnitTesting/Inspection-Rewrite
> ng test --code-coverage

05 12 2016 13:10:45.485:WARN [karma]: No captured browser, open http://localhost:9876/
05 12 2016 13:10:45.492:WARN [karma]: Port 9876 in use
05 12 2016 13:10:45.493:INFO [karma]: Karma v1.3.0 server started at http://localhost:9877/
05 12 2016 13:10:45.493:INFO [launcher]: Launching browser Chrome with unlimited concurrency
05 12 2016 13:10:45.497:INFO [launcher]: Starting browser Chrome
05 12 2016 13:10:47.739:INFO [Chrome 55.0.2883 (Linux 0.0.0)]: Connected on socket /#9FP78x92YrV-nPNoAAAA with id 77141340

START:

Finished in 0.003 secs / 0 secs

SUMMARY:
✔ 0 tests completed

But in other computers, the same branch runs npm install without any doubts. And it detects all test cases. Then I reinstalled node and npm on my computer. but Still, I get the same situation. Then I checked by running npm test on this project(https://github.com/lathonez/clicker) and it also gives the same result and doesn't detect any test cases. previously this project also run perfectly on my computer.

I can't understand what is going wrong. The problem is it my node or npm or karma configurations?

Please help me. Thanks...

Upvotes: 0

Views: 2109

Answers (1)

Yousuf
Yousuf

Reputation: 3285

It looks like a problem with chrome version 55. We had same problem this morning and we updated karma config file to use firefox instead of chrome.

For running tests in firefox, you need to add karma-firefox-launcher plugin and change browsers to firefox.

plugins: [
  require('karma-jasmine'),
  require('karma-firefox-launcher'),
  require('karma-remap-istanbul'),
  require('angular-cli/plugins/karma')
],


browsers: ['Firefox'],

Edit

Was able to get this working for chrome by adding below line karma.conf.js file.

mime: { 'text/x-typescript': ['ts','tsx'] }

Source: https://github.com/angular/angular-cli/issues/2125

Upvotes: 4

Related Questions