-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
Describe the bug
e.g.
const foundCompanies = useQueries({
queries: Array.from(
new Set(
Array.from(meetingNotesProspectsCompanyIds).concat(
Array.from(meetingNotesParticipantsCompanyIds)
)
)
).map((companyId) => {
return {
queryFn: async () => {
return await CompanyApi.getCompanyForMeetingSummary({
companyId: Number(companyId),
});
},
queryKey: ["company", { entityId: Number(companyId) }],
refetchOnWindowFocus: false,
};
}),
});
in test CompanyApi.getCompanyForMeetingSummary is mocked but in test run I get:
console.error
Error: Query data cannot be undefined
at Object.onSuccess (/Users/gregoryorton/Engineering/Projects/Thrive/Products/Drive/Code/front-end/node_modules/@tanstack/query-core/build/esm/index.js:1097:19)
at resolve (/Users/gregoryorton/Engineering/Projects/Thrive/Products/Drive/Code/front-end/node_modules/@tanstack/query-core/build/esm/index.js:562:50)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
and
expect(CompanyApi.getCompanyForMeetingSummary).toBeCalledTimes(1);
results
expect(jest.fn()).toBeCalledTimes(expected)
Expected number of calls: 1
Received number of calls: 0
Your minimal, reproducible example
I don't have one
Steps to reproduce
jest.mock("stores/requests/Company", () => ({
getCompanyForMeetingSummary: jest.fn().mockResolvedValue({ ... })
see useQueries definition above
Expected behavior
The mocked functions are executed
How often does this bug happen?
Every time
Screenshots or Videos
Platform
- OS: MacOs latest
- Browser: Chrome latest
react-query version
^4.0.10
TypeScript version
^4.4.3
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels
