Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma Jasmine tests always fails with stacktrace at line 9

I have a weird problem. Whenever I'm trying to test something and the test fails, it always shows a stacktrace with line number 9.

I'm using AngularJS along with Jasmine and Karma. I found out that it doesn't depend on the browser. An error looks like this:

TypeError: 'undefined' is not an object (evaluating 'new google.maps.LatLng')
    at /Users/user1/project1/test_ctrl.js:9
    at /Users/user1/project1/spec/test_ctrl_spec.js:170

So, it tells me that the test fails on line 170 (this is correct), but the cause of the error is inside my test_ctrl.js at a complete different line number than number 9. And this line number is shown on every test that fails.

Anyone an idea how to solve this?

like image 980
23tux Avatar asked May 29 '14 16:05

23tux


People also ask

What is karma in testing?

Karma is essentially a tool which spawns a web server that executes source code against test code for each of the browsers connected. The results of each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.

How do you skip the Jasmine test?

Excluding Tests / Specs If you want to exclude a specific test, simply use xit() instead of it() . The x means exclude. describe('description', function () { xit('description', function () {}); }); If you want to exclude an entire describe block, use xdescribe() instead of describe() .


1 Answers

This appears to be an issue with using karma-coverage, since the istanbul code coverage tool minifies the source code. There is an open issue on the karma-coverage repo. If you temporarily disable the coverage reporter in your karma config file, it should work fine.

like image 172
Andrew Avatar answered Oct 06 '22 00:10

Andrew