Search code examples
angularjsjasmineistanbulkarma-coverage

Karma Istanbul fix to work with new version of Chrome


In my AngularJs application I'm using Jasmine and Karma for my unit tests.

Recently, after a chrome update (now on 72.0.3626.81) my unit tests starting failing locally (with no change to code). I believe the error is a result of my coverage tool Instanbul.

Sometimes the error appears like this:

An error was thrown in afterAll Uncaught ReferenceError: __cov_iuQO6FdumXRPLjSMopb0JQ is not defined thrown

Other times it will appear within a specific unit test (not sure why).

I searched my application and the only file this __cov_ variable could come from is the return of a function within the Instanbul package, generateTrackerVar() within instrumenter.js.

As no code changes were made I assume that the issue is with the new version of Chrome, perhaps the security settings.

My question what permissions would karama-coverage/istanbul require? OR if anyone suspects the issue isn't security based, then what could be causing this error?

Thanks

EDIT: I have tried to disable web security in my gulpfile like so:

browsers: [ 'Chrome_without_security' ],
customLaunchers: {
    Chrome_without_security: {
        base: 'Chrome',
        flags: ['--disable-web-security']
    }
},

But this didn't solve the issue. Is there a way to set the chrome version in this config?


Solution

  • I managed to solve this by figuring out the hashcode after __cov_ was related to a test file that was throwing an error. I don't know why the error didn't just appear as it normally would, that will be another problem to solve.

    For now I managed to figure out the file by logging in instrumenter.js within the instanbul package. Then by removing my coverage tool I figured out the source of the issue. Simply removing the coverage tool would give me a different error but not tell me which file so I needed to do both.