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.

MockModule: template parse errors

See original GitHub issue

Hello, 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:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
ike18tcommented, Nov 6, 2018

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.

2reactions
satanTimecommented, Nov 7, 2018

Works well for me! Thanks!

Read more comments on GitHub >

github_iconTop 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 >

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