Apollo tests fail with --codeCoverage but pass without
See original GitHub issueIntended outcome:
Running ng test --codeCoverage=true --no-watch
should pass, since running without --codeCoverage
passes
Actual outcome:
The test fails with TypeError: Cannot read property 'use' of undefined
this looks to be in (http://localhost:9877/_karma_webpack_/node_modules/apollo-angular/fesm2015/ngApollo.js:239:1). It seems Apollo is not being injected correctly.
How to reproduce the issue:
When testing a Query
from apollo-angular in a service (not a component) the tests will pass when run normally but will fail when generating code coverage. See the repository at https://github.com/aaraggornn/apollo-error-test for a reproduction.
Run npm run test
to pass and npm run test:cc
to fail (using --codeCoverage)
Versions “apollo-angular”: “^1.7.0”, “apollo-client”: “^2.6.4”, “typescript”: “~3.5.3”, “@angular/core”: “~8.2.8”, “graphql”: “^14.5.8”, “graphql-tag”: “^2.10.1”,
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:7
Top GitHub Comments
@aaraggornn I have found a temporary workaround. You’ll need to inject
Apollo
manually in the extendedMutation
class and callsuper()
with the provided apollo instance:It will work with
--codeCoverage
turned on.This also happens with apollo-angular 1.8.0