0

I am trying to use storybook with this library and have a test component that uses the MatRadioModule from Material. I get the following error in my Jest unit test.

Template parse errors: 'mat-radio-button' is not a known element: 1. If 'mat-radio-button' is an Angular component, then verify that it is part of this module. 2. If 'mat-radio-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("

My storybook and unit tests work until I try to use Material components, and then it breaks.

Caleb Edwards
  • 11
  • 1
  • 4
  • You need to import the MatRadioModule to your test module. – Baruch Jun 02 '20 at 20:30
  • I do have MatRadioModule imported in the test module, but it is still not finding it. Could my configuration be wrong in using Material to where it won't find any of Material's components? – Caleb Edwards Jun 02 '20 at 21:11

2 Answers2

0

this question has been answered here.

In general, code that your libraries depend on should be added to the peerDependencies in the package.json of that library.

Hope this helps.

  • I have @angular/material in the dependencies of my package.json. I read that this is possible, but am still having no luck finding material components. Is something else needed for this to work? – Caleb Edwards Jun 03 '20 at 14:51
0

Figured it out. Had to import the Angular Component into the spec file and story for those frameworks to work with Material.

Caleb Edwards
  • 11
  • 1
  • 4