简体   繁体   English

使用VMware Clarity模块进行Angular 2单元测试

[英]Angular 2 unit testing with VMware Clarity modules

I'm doing a POC for an angular 2 project that's using VMware's Clarity components. 我正在为使用VMware的Clarity组件的angular 2项目做POC。 When I run the test runner, I'm getting the following errors: 当我运行测试运行程序时,出现以下错误:

'clr-main-container' is not a known element:
1. If 'clr-main-container' is an Angular component, then verify that it is part of this module.
2. If 'clr-main-container' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<clr-main-container>

I'm new to angular 2 and I'm not able to find anything on Google. 我是Angle 2的新手,无法在Google上找到任何内容。

Hi agillette , you are probably missing the Testbed configuration in your tests. 嗨, 吉列 ,您的测试中可能缺少测试平台配置。 Something like: 就像是:

 import {async, ComponentFixture, TestBed} from "@angular/core/testing"; import {ClarityModule} from 'clarity-angular'; describe('...', function() { beforeEach(() => { TestBed.configureTestingModule({ imports: [ClarityModule.forRoot()], declarations: [YourTestComponent] }); }); }); 

You can read more about the TestBed here . 您可以在此处阅读有关TestBed的更多信息。

Also feel free to check out the Clarity seed for a simple working application with testing wired in. 也可以随时通过连接测试来查看Clarity种子 ,以获取简单的工作应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM