是角度单位测试的新手。
我想实施第一个运行测试,所以我开发了这个:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
let component: AppComponent;
let fixture: ComponentFixture<AppComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AppComponent ],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('first test', () => {
expect('1').toBe('1');
});
});
就像你看到我的第一个测试是断言“1”是“1”,我不知道为什么我面临成功的问题,因为它给我带来了这样的错误:
Error: Template parse errors: Can't bind to 'min' since it isn't a known property of 'dx-progress-bar'.
1. If 'dx-progress-bar' is an Angular component and it has 'min' input, then verify that it is part of this module.
2. If 'dx-progress-bar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
width="100%"
[class.complete]="progressBar.value == maxValue"
[ERROR ->][min]="0"
[max]="maxValue"
[statusFormat]="wordProgression" "): ng:///DynamicTestModule/AppComponent.html@15:4
我在我的应用程序组件中使用DevExtreme小部件确实如此,但我甚至都没有尝试过测试它。我只是从明显的测试用例开始。
我需要知道如何解决它?
建议??
答案 0 :(得分:2)
您必须在TestBed.configureTestingModule
中包含编译组件所需的所有内容:
// import { DevExtremeModule } from 'devextreme-angular';
import { DxProgressBarModule } from 'devextreme-angular/ui/progress-bar';
TestBed.configureTestingModule({
imports: [
DxProgressBarModule,
// or DevExtremeModule
],
declarations: [ AppComponent ],
}).compileComponents();