-
-
Notifications
You must be signed in to change notification settings - Fork 188
Closed
Description
Hi,
I wrote the below unit test using @ngneat/spectator
const createComponent = createComponentFactory({
component: TableComponent,
shallow: true,
declarations: [MockComponent(SingleSelectComponent)],
imports: [
FormsModule,
ReactiveFormsModule,
ButtonModule,
DropdownModule,
RadioButtonModule,
HttpClientTestingModule,
TooltipModule,
TableModule,
AutoCompleteModule,
InputSwitchModule,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [{
provide: Service,
useValue: {
fetchRecords: () => of({}),
add: () => of({}),
getDetails: () => of({}),
}
}
]
});
beforeEach(() => {
spectator = createComponent();
service = spectator.inject(Service);
});
it('should create', () => {
expect(spectator.component).toBeTruthy();
});
it('should set intial values for rowsPerPageOptions', () => {
expect(spectator.component.tableRowsPerPageOptions.length).toEqual(3);
const rowsPerPageOptions = [10, 20, 50];
spectator.component.tableRowsPerPageOptions.forEach((option, i) => {
expect(option).toEqual(rowsPerPageOptions[i]);
})
});
But when I ran the above test, I am getting the below error. Can you please tell me what I am doing wrong
TableComponent > should set intial values for rowsPerPageOptions
Failed: Cannot read properties of undefined (reading 'length')
error properties: Object({ longStack: 'TypeError: Cannot read properties of undefined (reading 'length')
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels