Tag: test

Jest: How to mock a single hook from a module

crysfel Programming

Today I needed to write a test for a component that uses a hook from our common library, but at the same time I needed to use other components in the test. Initially I mocked the whole module and got all previous tests to fail, the issue was that I mocked everything and no other component was working as expected. Here's the code I wanted to test. import { Text, File, useToast } from '@my-library/ui'; import axios from 'axios'; export default function Uploader({ userId ) { const showToast = Continue reading