**● TestComponent › 应该创建
TypeError: Cannot read properties of undefined (reading 'userIds')
2 | import { TestReducers } from '../reducers';
3 |
> 4 | export const getuserIds = createSelector(TestReducers.TestFeatureSelector, state => state.userIds);**
| ^
describe('TestComponent', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;
>! let store: MockStore<State>;<kbd>your text</kbd>
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [TestComponent], // Replace with the actual declarations used in TestComponent.
providers: [
provideMockStore({
initialState: {
userIds: '1234'
},
}),
],
}).compileComponents();
fixture = TestBed.createComponent(TestComponent);
store = TestBed.inject(MockStore<State>);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
下面是我使用组件的选择器 userId = this.store.selectSignal(getUserIds);
以下是我的选择器 导出 const getUserIds = createSelector(TestReducers.TestFeatureSelector, state => state.userIds);