I just updated react-scripts to 4.0 which includes Jest@26 and some accompanying test packages here's the package.json diff:
After upgrading, some Jest mocks have begun to fail. It seems like the mocked return value is just undefined? Am I missing something? Here's one of the failing mocks
import useFetch from "use-http";
jest.mock("use-http", () => ({
__esModule: true,
default: jest.fn()
}));
describe("the user context", () => {
beforeAll(() => {
useFetch.mockReturnValue({
get: async () => Promise.resolve({ foo: 666 }),
response: { ok: true }
});
});
Tests that try to utilize the 'get' method fail with:
TypeError: Cannot destructure property 'get' of '(0 , _useHttp.default)(...)' as it is undefined.
And another that isn't default, doesn't import the package for one-time mocks:
jest.mock("_hooks", () => ({
useBaseUrls: jest.fn().mockReturnValue({
app: "bar"
})
}));
Tests that access the 'app' property throw TypeError: Cannot read property 'app' of undefined
