Skip to content
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

Breaks source map if error message contain url without line number and column #1274

Closed
maksimr opened this issue Dec 21, 2014 · 7 comments · Fixed by #1915 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132
Closed
Assignees
Milestone

Comments

@maksimr
Copy link
Contributor

maksimr commented Dec 21, 2014

We have two cases when it possible

  • In latest version of karma-jasmine when test contain variable which does not defined we have error message:
ReferenceError: plus is not defined in http://localhost:9876/base/test.js?5e4e9f0005ec2172d5edc1234305ab74e3267861 (line 6)
  • Firefox sometimes throw error with formatted stack trace. (NOTE: Maybe it's first case)
  • Rare case. User can define test cases or test suites which contain url, for example:
it('should go to the http://lolcalhost/base/rest', function(){...})

In those three cases reporter.js breaks with error:

ERROR [karma]: [TypeError: Line must be greater than or equal to 1, got 0]
TypeError: Line must be greater than or equal to 1, got 0
@dignifiedquire
Copy link
Member

@maksimr are you actually working on this? I added it to the 1.0 milestone as it feels like this is something that needs fixing.

@maksimr
Copy link
Contributor Author

maksimr commented May 19, 2015

@dignifiedquire
Now dont work, but I will look at it on this week

@dignifiedquire
Copy link
Member

Okay cool

@Nathan219
Copy link

I have managed to get this error to happen when I had a unit test still being ran meant to test a service that no longer existed. I managed to see an angular 'Unknown provider' error when I ran the tests in debug (in webstorm).

@dignifiedquire
Copy link
Member

@maksimr any updates on this?

@bailsman
Copy link

bailsman commented Feb 9, 2016

This patch fixes at least the jasmine case for me (didn't test the others).
How naive is this fix?

diff --git a/lib/reporter.js b/lib/reporter.js
index 9bcbab0..8c62cfe 100644
--- a/lib/reporter.js
+++ b/lib/reporter.js
@@ -49,7 +49,7 @@ var createErrorFormatter = function (basePath, emitter, SourceMapConsumer) {

       var file = findFile(path)

-      if (file && file.sourceMap) {
+      if (file && file.sourceMap && line) {
         line = parseInt(line || '0', 10)

         column = parseInt(column, 10)

davidparsson added a commit to davidparsson/karma that referenced this issue Feb 18, 2016
There is no way to resolve them in this case anyway. Fixes karma-runner#1274.
@davidparsson
Copy link
Contributor

Thanks for the pointer, @codeHotter. I implemented that in the PR above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants