This repository was archived by the owner on Dec 5, 2024. It is now read-only.
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
fix: useFetch in jest unit testsΒ #437
Open
Description
π The bug
When unit testing a component that uses useFetch composable, I'm getting weird error.
π οΈ To reproduce
Steps to reproduce the behavior:
- Create a component that uses setup function with useFetch composable inside of it
- Write a test suite with any unit test of said component
- See error
I'd be very grateful for a link to a gist or repo that reproduces the bug.
π Expected behaviour
The test suite runs smoothly
βΉοΈ Additional context
My component
export default defineComponent({
setup() {
const { fetch } = useFetch(async () => {
//
});
return {
//
};
},
My test suite
describe('MainSearch', () => {
let wrapper!: Wrapper<any>;
const factory = (data?: object) => shallowMount(MainSearchComponent, {
stubs: {
...
},
vuetify: new Vuetify(),
});
beforeEach(() => {
wrapper = factory();
});
afterEach(() => {
wrapper.destroy();
});
it('should match snapshot', () => {
expect(wrapper.html())
.toMatchSnapshot();
});