Skip to content

Flakey unit test in CI: store.saga.test.ts #1468

@tyler-dane

Description

@tyler-dane

Where did this happen?

No response

Expected Behavior

No response

Current Behavior

The primary failure is caused by a TypeError: Cannot read properties of undefined (reading 'request') in packages/web/src/store/sagas.ts at lines where takeLatest is used with .actions.request (see logs and code). This happens because, in your test (packages/web/src/views/Forms/hooks/useSaveEventForm.test.ts), the createEventSlice, editEventSlice, etc., are mocked and expected to have an actions property containing the request key. However, the actual test mock only defines request on some slices, leaving others as empty reducers.

Solution: Ensure that all slices used in packages/web/src/store/sagas.ts (such as getDayEventsSlice, getWeekEventsSlice, getCurrentMonthEventsSlice, etc.) are properly mocked in the test file, each with an actions object containing a request property (even if it’s just a jest.fn()). Update your mock for these slices:

Replace in your test mock (useSaveEventForm.test.ts):

Steps to Reproduce

No response

Possible Solution

Replace in your test mock (useSaveEventForm.test.ts):

getDayEventsSlice: { reducer: jest.fn(() => ({})) },
getSomedayEventsSlice: { reducer: jest.fn(() => ({})) },
getWeekEventsSlice: { reducer: jest.fn(() => ({})) },
getCurrentMonthEventsSlice: { reducer: jest.fn(() => ({})) },

With

getDayEventsSlice: { actions: { request: jest.fn() }, reducer: jest.fn(() => ({})) },
getSomedayEventsSlice: { actions: { request: jest.fn() }, reducer: jest.fn(() => ({})) },
getWeekEventsSlice: { actions: { request: jest.fn() }, reducer: jest.fn(() => ({})) },
getCurrentMonthEventsSlice: { actions: { request: jest.fn() }, reducer: jest.fn(() => ({})) },

Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    devopsCI/CD, e2e tests, infraneeds more infoNot ready for coding just yet

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions