question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

For polyfill es7/reflect, it should be mentioned that tests are not run in AOT mode

See original GitHub issue

From @fredgate on January 25, 2018 11:7

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Area

- [ ] devkit
- [x] schematics

Versions

angular CLI 1.6.4

Repro steps

Use AOT to serve and build the application.

In the polyfills.ts file, comment the import 'core-js/es7/reflect'; line as it is mentioned that :

/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
// import 'core-js/es7/reflect';

Then execute unit tests. Tests where a provider (the system under test, or any other class) has a injected dependency will fail with a message indicating that it can resolve all parameter for the class. It is not because its dependencies are not registered in the testing module, but because it can not read metadata of the class and so determine the dependant classes.

The log given by the failure

Error: Can't resolve all parameters for MyService: (?). in http://localhost:9876/_karma_webpack_/vendor.bundle.js (line 20595)
syntaxError@http://localhost:9876/_karma_webpack_/vendor.bundle.js:20595:34
../../../compiler/esm5/compiler.js/CompileMetadataResolver.prototype._getDependenciesMetadata@http://localhost:9876/_karma_webpack_/vendor.bundle.js:35802:35

Desired functionality

The polyfills.ts should mention for the es7/reflect polyfill that unit tests are not run in AOT mode.

Copied from original issue: angular/devkit#408

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

9reactions
penfoldcommented, Apr 10, 2019

@ravioshankar It doesn’t work with core-js 3. Revert to 2.6.5 fixed the same error for me…

npm install core-js@2.6.5 --save

1reaction
ravioshankarcommented, Apr 8, 2019

Getting similar issue on ubuntu CLI version is “@angular/cli”: “~7.3.8”, “@angular-devkit/build-angular”: “~0.13.8”,

ERROR in ./node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/jit-polyfills.js Module not found: Error: Can’t resolve ‘core-js/es7/reflect’ in ‘/home/openworkshop/git/prithvi/node_modules/@angular-devkit/build-angular/src/angular-cli-files/models’ ERROR in ./src/polyfills.ts Module not found: Error: Can’t resolve ‘core-js/es7/reflect’ in ‘/home/openworkshop/git/prithvi/src’ ℹ 「wdm」: Failed to compile.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular/angular - Gitter
I have just found that if I remove import 'core-js/es7/reflect'; in polyfills, all my test will go fail with components using DI.
Read more >
Angular app not open in Edge it redirect to open in IE 11 ...
My angular 5 App is working fine in chrome,firefox. but when i tried to open in Microsoft Edge(WIN10 OS), Application is always open...
Read more >
What's new in Angular CLI 7.0? | Ninja Squad
Along the same lines, a new flag called --minimal will generate a workspace with a project, but with the bare minimum: no unit...
Read more >
Whats New in Angular 7.x - LinkedIn
On the polyfill side, the reflect-metadata polyfill (core-js/es7/reflect) is now only included in JiT mode, as it is not needed in AoT ......
Read more >
Learning Angular: Boot Up Process - Red Green Repeat
I will go through the process I took in learning how Angular boots ... The index.html does not show test 6 app anywhere...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found