how-to-test-useeffect-api-call/
Opened this issue · 5 comments
Testing API Calls in useEffect using React Testing Library and Jest | Tania Rascia
Ever since Hooks were released in React, we've been using the hook to fetch data, whether directly or abstracted away behind Redux Thunks…
Always nice to read your posts! Keep writing!
Nice concise material, thank you for sharing!
So like to read your posts!
You have seldom talent of writing simple about complicate things
Getting error in this line fetchMock.mockResolvedValue({ status: 202, type: jest.fn(() => fakeResponse) })
module.exports = {
moduleNameMapper: {
'\.(scss|css)$': "/tests/mocks/styleMock.js",
'\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': "/tests/mocks/styleMock.js",
},
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!<rootDir>/node_modules/",
"!<rootDir>/src/CMTheme.js"
],
"coverageThreshold": {
"global": {
"branches": 60,
"functions": 60,
"lines": 60,
"statements": 60
}
},
};
this my jest.config file, should i have to add the all the config you provided here ? could you please assist im really struggling with this mocking thing