I am trying to test a component containing ngx-treeview. I wrote the following test, but it fails with the error message contained in the title (obviously except the in unit test part):
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { TreeviewConfig, TreeviewItem, TreeviewModule } from 'ngx-treeview';
import { TabTreeviewComponent } from './tab-treeview.component';
describe('TabTreeviewComponent', () => {
let component: TabTreeviewComponent;
let fixture: ComponentFixture<TabTreeviewComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ TabTreeviewComponent ],
imports: [ TreeviewConfig, TreeviewItem, TreeviewModule.forRoot() ],
providers: [ ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TabTreeviewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
const config = TreeviewConfig.create({
hasAllCheckBox: false,
hasFilter: true,
hasCollapseExpand: true,
maxHeight: 435
});
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
I already tried initializing the TreeviewConfig as a declaration without any avail apparently. I also tried providing it as a provider - that also did not help at all... I am unsure what else could I try at this point, TestBed must have a way to include the config for the TreeView somehow or am I making a logical fallacy here?
The error is being thrown because you are including non modules on the
inports
arrayBasically you only need to import
TreeviewModule