MockModule: template parse errors
See original GitHub issueHello, I have just updated library in version 7.1.0.
I mocked MatDialogModule by this way imports: [MockModule(MatDialogModule)]
,
But have got this error :
Error: Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) ("tter"]();
return _this;
}"><template [ngTemplateOutlet]="_portalOutlet"></template></div>[ERROR ->]"): ng:///MockedModule/MockOfMatDialogContainer.html@10:69
Invalid ICU message. Missing '}'. ("tter"]();
return _this;
}"><template [ngTemplateOutlet]="_portalOutlet"></template></div>[ERROR ->]"): ng:///MockedModule/MockOfMatDialogContainer.html@10:69
at syntaxError (http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:2547:1)
at DirectiveNormalizer.push../node_modules/@angular/compiler/fesm5/compiler.js.DirectiveNormalizer._preparseLoadedTemplate (http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:14102:1)
at http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:14094:62
at Object.then (http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:2538:33)
at DirectiveNormalizer.push../node_modules/@angular/compiler/fesm5/compiler.js.DirectiveNormalizer._preParseTemplate (http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:14094:1)
at DirectiveNormalizer.push../node_modules/@angular/compiler/fesm5/compiler.js.DirectiveNormalizer.normalizeTemplate (http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:14080:1)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.loadDirectiveMetadata (http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:17282:1)
at http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:24906:1
at Array.forEach (<anonymous>)
at http://localhost:9876/node_modules/@angular/compiler/fesm5/compiler.js?:24905:1
I think, it comes from the MatDialogContainer template, as mentioned in error message.
I do not have this error if I only mock what I need:
declarations: [
...
MockDirectives(MatDialogTitle, MatDialogClose),
MockComponents(MatDialogContent, MatDialogActions),
],
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
How to fix Template parse errors: <component> is not a known ...
A solution for Angular tests when they fail with "Template parse errors: is not a known element"
Read more >MockModule: template parse errors · Issue #28 - GitHub
I mocked MatDialogModule by this way imports: [MockModule(MatDialogModule)], But have got this error : Error: Template parse errors: ...
Read more >Failed: Template parse errors: Can't bind to 'routerLink' since it ...
I tried to add CUSTOM_ELEMENTS_SCHEMA to the app component.spec.ts stil the got the same error, Where is your test spec file? You are...
Read more >ng-mocks - npm
Template parse errors : <component> is not a known element ... To create a mock module in Angular tests with ng-mocks is quite...
Read more >angular.mock.module - AngularJS: API
Declarative templates with data-binding, MVC, dependency injection and great testability story all implemented with pure client-side JavaScript!
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry about that, I was out of town and left my computer at home. 😃
I have merged the PR and I’ll try to get a new version released when I get home from work.
Works well for me! Thanks!