Gulp Karma "Script error"

309 Views Asked by At

I'm using gulp-karma + mocha + chai + sinon in order to unit test some front end.

The nasty thing I keep getting into is the "Script Error" message that karma spits out without any other relevant detail.

How can I make karma display the source of the error also ?

enter image description here

1

There are 1 best solutions below

0
On

This might be a little late, but as others may find this problem I thought I'd add some notes.

The Script error comes when the error is produced in a different domain than it's consumed. Browsers then remove the error details for security reasons. Typically this happens if:

  • you load scripts/pages from different domains
  • you run eval code. Note that this is what webpack often does in development scenarios

To mitigate this you can

  • add relevant HTTP CORS headers
  • skip running eval code - if you're running webpack, choose a devtool not containing "eval"
  • load resources from the same domain

Hope it helps