-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to have stories without mocks with this addon #21
Comments
I have the same problem with the addon but i think i found a temporary solution. The Problem is that in the @JohnAlbin i think the issue starts add Line 76 in the Since we know that the parameters object is undefined i think you could skip the complete rest of the code except some think like this: // When parameters is undefined, render the story
if(!parameters)
return storyFn(context);
// Add all the mocks.
addMocks(parameters.mocks);
// Do any additional configuration of fetchMock, e.g. setting
// fetchMock.config or calling other methods.
if (typeof parameters.useFetchMock === 'function') {
parameters.useFetchMock(fetchMock);
}
// Add any catch-all mocks.
addMocks(parameters.catchAllMocks, 'catchAllMocks');
// Add any catch-all urls last.
if (Array.isArray(parameters.catchAllURLs)) {
parameters.catchAllURLs.forEach((url) => {
fetchMock.mock(
{
// Add descriptive name for debugging.
name: `catchAllURLs[ ${url} ]`,
url: `begin:${url}`,
},
// Catch-all mocks will respond with 404 to make it easy to determine
// one of the catch-all mocks was used.
404,
);
});
}
// Render the story with mocks.
return storyFn(context); @Slessi for the meentime, you can just add a empty parameters: {
fetchMock: {},
}, |
I need mocks for some, but not all stories. I am seeing the below error, for any story that does not define mocks:
TypeError: Cannot read properties of undefined (reading 'mocks')
Reproduction: https://github.com/Slessi/storybook-addon-fetch-mock-no-data-repro
I expect to be able to have stories without mocks, is this not possible? Am trying to migrate from
storybook-addon-mock
which allowed for this.There was a similar issue at #6 but the author claims it was a problem on his end, however in my minimal reproduction I cannot imagine what I am doing wrong.
The text was updated successfully, but these errors were encountered: