taniarascia / comments

Comments
7 stars 0 forks source link

how-to-test-useeffect-api-call/ #133

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

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…

https://www.taniarascia.com/how-to-test-useeffect-api-call/

adriano-lemos-dev commented 1 year ago

Always nice to read your posts! Keep writing!

Ker7 commented 1 year ago

Nice concise material, thank you for sharing!

shootermv commented 1 year ago

So like to read your posts! You have seldom talent of writing simple about complicate things

TanuAgrawal123 commented 1 year ago

Getting error in this line fetchMock.mockResolvedValue({ status: 202, type: jest.fn(() => fakeResponse) })

phani1585 commented 1 year ago

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