Open zz-james opened 3 months ago
Hey, it should be alongside with the things you are trying to mock
for example if you have some query hook which is importing api function:
import { someQuery } from './someQuery';
const useSomeQuery = () => {
return useQuery(() => someQuery(...));
}
you need to create __mocks__
in this direction, to mock the ./someQuery
import. You need to create __mocks__/someQuery.ts
in current directory
This addon is just adding __mocks__
prefix to all your imports, and checking if there are any mock exists for the prefix. Think about it like that.
./someQuery
, it will going to try to use __mocks__/someQuery
If your import is ../someQuery
, it will going to try to use ../__mocks__/someQuery
(not sure about this one)
Here is the code responsible for it, I definitely need to add some tests for this method and test most of the paths
everything is working now, thank you.
Hi At my workplace the storybook stories are all in their own 'stories' folder.
This means that reading the 'How to use' sectioin of the docs, is ambiguos for me, if the folder path for the mock is mocks then does this live alongside the 'stories' or alongside the 'component'
I've tried both, and at the moment neither work, but I would like to make sure I have it right before further attempts to fix it.
Many thanks
James