我有這個簡單的組件簡單Angular2組件:茉莉花測試不工作
@Component({
selector: 'messages',
styleUrls: ['messages.component.scss'],
templateUrl: 'messages.component.html',
})
export class MessagesComponent implements OnInit {
constructor(private dataService: DataService) {}
public getOne(): number{
return 1;
}
}
我試圖運行它的測試,但我不能讓它工作,請幫助:
describe('Component: MessagesComponent',() => {
let component: MessagesComponent;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [MessagesComponent],
}).compileComponents();
const fixture = TestBed.createComponent(MessagesComponent);
component = fixture.componentInstance;
});
it('should have a defined component',() => {
expect(true).toBeTruthy();
});
});
(我用的WebPack如果是相關的)
這是錯誤我得到:
Error: This test module uses the component MessagesComponent
which is using a "templateUrl", but they were never compiled.
Please call "TestBed.compileComponents" before your test.