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

Use default value that's safe with source-map@0.1.43 #1310

Conversation

mtscout6
Copy link
Member

source-map@0.1.43 will throw an error if you pass a line number equal to
0. See:
https://github.com/mozilla/source-map/blob/0.1.43/lib/source-map/source-map-consumer.js#L285-L287

Since Karma is not wrapping that in a try catch, the exception will just crash karma. Changing the default line number to 1 will not throw and a test exception stack trace will still output correctly.

@mtscout6
Copy link
Member Author

@karma/owners ping

@mtscout6
Copy link
Member Author

I would put fix(***) in the commit message, but I'm not sure what to put in the parenthesis for this.

@maksimr
Copy link
Contributor

maksimr commented Feb 25, 2015

@mtscout6 Thanks.

When line is not defined or equal '0'?
Because line equal '0' is symptom not the root of the problem. (IMHO)
Please add test for this fix (example of test you can take from PR #1098).

I would put fix(***) in the commit message, but I'm not sure what to put in the parenthesis for this.

fix(reporter): ...

@maksimr
Copy link
Contributor

maksimr commented Feb 25, 2015

Related issues #1274, #1098

@mtscout6
Copy link
Member Author

I understand your sentiment about feeling like this is just fixing the symptom, so let me explain the issue a little deeper. I'm currently seeing this issue isolated to Firefox.

For example without my fix I get the following output and the karma process crashes, it does not matter it the error is in a test or the code being tested.

➜  one-exchange git:(team-4) ✗ karma start
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [launcher]: Starting browser Firefox
INFO [launcher]: Starting browser PhantomJS
INFO [Firefox 34.0.0 (Mac OS X 10.10)]: Connected on socket z-Wd2IS8Ga2bGoA-4Djx with id 96357773
INFO [Chrome 40.0.2214 (Mac OS X 10.10.2)]: Connected on socket SWejfJH3UCtjk3Xw4Djw with id 61391085
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket EY2QNttHkOjUIX4A4Djy with id 82304088
PhantomJS 1.9.7 (Mac OS X) Directive: addToCart toggles the text FAILED
        ReferenceError: Can't find variable: test
            at /mnt/Resources/dev/one-exchange/src/ExtendHealth.OneExchange/content/scripts/specs/test-main.js:218:0 <- webpack:///src/ExtendHealth.OneExchange/content/scripts/specs/add-to-cart-directive-spec.js:58:0
PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.609 secs PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.609 secs / 0.02 secs)
Firefox 34.0.0 (Mac OS X 10.10): Executed 0 of 2002 SUCCESS (0 secs / 0 secs)
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
    at SourceMapConsumer_findMapping [as _findMapping] (/mnt/Resources/dev/one-exchange/node_modules/source-map/lib/source-map/source-map-consumer.js:286:15)
    at SourceMapConsumer_originalPositionFor [as originalPositionFor] (/mnt/Resources/dev/one-exchange/node_modules/source-map/lib/source-map/source-map-consumer.js:346:24)
    at /mnt/Resources/dev/one-exchange/node_modules/karma/lib/reporter.js:49:28
    at String.replace (native)
    at /mnt/Resources/dev/one-exchange/node_modules/karma/lib/reporter.js:36:23
    at /mnt/Resources/dev/one-exchange/node_modules/karma/lib/reporters/base.js:105:14
    at Array.forEach (native)
    at specFailure (/mnt/Resources/dev/one-exchange/node_modules/karma/lib/reporters/base.js:104:16)
    at onSpecComplete (/mnt/Resources/dev/one-exchange/node_modules/karma/lib/reporters/base.js:85:12)
    at null.<anonymous> (/mnt/Resources/dev/one-exchange/node_modules/karma/lib/events.js:15:22)

With the fix:

➜  one-exchange git:(team-4) ✗ karma start
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [launcher]: Starting browser Firefox
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket jpJiybv612ww-62s5lpN with id 96250461
INFO [Chrome 40.0.2214 (Mac OS X 10.10.2)]: Connected on socket s1OMD9qBcbfgwpK35lpM with id 61230800
INFO [Firefox 34.0.0 (Mac OS X 10.10)]: Connected on socket IV13FDfieF_aEtCk5lpO with id 9808170
PhantomJS 1.9.7 (Mac OS X) Directive: addToCart toggles the text FAILED
        ReferenceError: Can't find variable: test
            at /mnt/Resources/dev/one-exchange/src/ExtendHealth.OneExchange/content/scripts/specs/test-main.js:218:0 <- webpack:///src/ExtendHealth.OneExchange/content/scripts/specs/add-to-cart-directive-spec.js:58:0
PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.562 secs PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.562 secs Firefox 34.0.0 (Mac OS X 10.10) Directive: addToCart toggles the text FAILED
        ReferenceError: test is not defined in /mnt/Resources/dev/one-exchange/src/ExtendHealth.OneExchange/content/scripts/specs/test-main.js:1:0 <- null:0:0 (line 218)
        __WEBPACK_AMD_DEFINE_RESULT__</</<@/mnt/Resources/dev/one-exchange/src/ExtendHealth.OneExchange/content/scripts/specs/test-main.js:218:10 <- webpack:///src/ExtendHealth.OneExchange/content/scripts/specs/add-to-cart-directive-spec.js:58:0

PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.562 secs PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.562 secs / 0.02 secs)
PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.562 secs / 0.02 secs)
Chrome 40.0.2214 (Mac OS X 10.10.2) Directive: addToCart toggles the text FAILED
        ReferenceError: test is not defined
            at null.<anonymous> (/mnt/Resources/dev/one-exchange/src/ExtendHealth.OneExchange/content/scripts/specs/test-main.js:218:10 <- webpack:///src/ExtendHealth.OneExchange/content/scripts/specs/add-to-cart-directive-spec.js:58:0)
PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.562 secs / 0.02 secs)
PhantomJS 1.9.7 (Mac OS X): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.562 secs / 0.02 secs)
Firefox 34.0.0 (Mac OS X 10.10): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (1.25 secs / 0.031 secs)
Chrome 40.0.2214 (Mac OS X 10.10.2): Executed 1 of 2002 (1 FAILED) (skipped 2001) ERROR (0.987 secs / 0.058 secs)

I didn't realize it when I first submitted this pull request, but with my fix there's no Firefox exception details... Thoughts?

@mtscout6
Copy link
Member Author

After applying the patch from #1098 I'm seeing better results than I am with this. I'd rather see that one go through.

@mtscout6 mtscout6 closed this Feb 25, 2015
@maksimr
Copy link
Contributor

maksimr commented Feb 25, 2015

ReferenceError: test is not defined in /mnt/Resources/dev/one-exchange/src/ExtendHealth.OneExchange/content/scripts/specs/test-main.js:1:0 <- null:0:0 (line 218)

Strange output...

Are you use jasmine?

@mtscout6
Copy link
Member Author

Yes, and I'm sure it's an old version for this project....

@maksimr
Copy link
Contributor

maksimr commented Feb 25, 2015

@mtscout6 Thanks.
I think the problem in jasmine error formatter not in Firefox

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

Successfully merging this pull request may close these issues.

None yet

2 participants