karma-runner / karma-runner/karma-coverage

Issue with polyfills

Open
#187 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

I'm not sure if it is a karma-coverage or Istanbul issue, but it seems using polyfills that change primitive prototypes or some properties on the global object make karma unit-tests fail in a very obscure way.

It took me a lot of digging to come to this conclusion, as the error manifests itself with all tests failing and messages that look like

```
Error: [$injector:unpr] Unknown provider:
http://errors.angularjs.org/1.2.28/$injector/unpr?p0=
```

Usually when angular complains about an Unknown provider, it states the (sometimes obfuscated) name of the missing provider, but here we just have "Unknown provider:" with no name and a huge url encoded stack that doesn't help at all.

I suspect it might be more of a karma-coverage than Istanbul issue because the polyfill file is not supposed to get instrumented in my setup, but I saw two cases:
- one polyfill file that can be loaded but will generate the issue when included in the "coverage" preprocessor glob target (excluding it from preprocessing prevents the errors)
- one polyfill that will generate the errors even if it isn't included in the "coverage" preprocessor glob for instrumentation.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the two polyfill cases described: one included in the coverage preprocessor glob and one excluded from it. Compare Karma coverage and Istanbul behavior, using the AngularJS unknown-provider output to identify where the failure begins. Done means the responsible component and a reproducible cause are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
angularjs, javascript
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.