Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it’s suited for websites, Node.js projects, or anywhere that JavaScript can run.
How to reproduce it
component.component.html
<p>Component works!</p>
<app-subcomponent
></app-subcomponent>
component.component.spec.ts
...
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ComponentComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(ComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
...
Error message:
error properties: Object({ code: 304 })
at validateElementIsKnown (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:4942:23)
at elementStartFirstCreatePass (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:13661:9)
at ɵɵelementStart (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:13699:9)
at templateFn (ng:///ComponentComponent.js:17:9)
at executeTemplate (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:10534:9)
at renderView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:10356:13)
at renderComponent (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:11529:5)
at renderChildComponents (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:10216:9)
at renderView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:10381:13)
at ComponentFactory.create (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2020/core.mjs:12273:13)
Solution
Update declarations: []
– add a subcomponent.
...
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ComponentComponent, SubcomponentComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(ComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
...