You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Storyshots do not run addDecorator in config.js. I have global decorator defined in config.js that wraps any story with component that provides context with theme and utils. My stories work fine but storyshots testing fails because of context not being passed into component that requires it.
Steps to reproduce
Use global decorator in config.js that wraps story in context provider component with context that required by components in stories.
Please specify which version of Storybook and optionally any affected addons that you're running
// src/ThemeProvider.jsximportReactfrom'react';importPropTypesfrom'prop-types';importMomentUtilsfrom'material-ui-pickers/utils/date-fns-utils';importMuiPickersUtilsProviderfrom'material-ui-pickers/utils/MuiPickersUtilsProvider';importmomentfrom'moment-timezone';import{MuiThemeProvider,createMuiTheme}from'material-ui';importthemefrom'./theme';consttheme=createMuiTheme(theme);constThemeProvider=({ children })=>(<MuiPickersUtilsProviderutils={MomentUtils}moment={moment}><MuiThemeProvidertheme={theme}>{children}</MuiThemeProvider></MuiPickersUtilsProvider>);
// stories/Datepicker.story.jsimportReactfrom'react';import{storiesOf}from'@storybook/react';import{DatePicker}from'material-ui-pickers';import{ThemeProvider}from'../src';consthandleDateAction=action('DatePicker onChange');storiesOf('Components',module)// Local decorator must be added in order to fix tests// .addDecorator(storyFn => <ThemeProvider>{storyFn()}</ThemeProvider>).add('Datepicker',()=>(<DatePickervalue={Date.now()}invalidLabel="Invalid label"format="LL"animateYearScrolling={false}disableFutureopenToYearSelectiononChange={this._handleDateChange}/>));
Then I get an error:
console.error node_modules/material-ui-pickers/_shared/WithUtils.js:33
Utils should be provided
console.error node_modules/fbjs/lib/warning.js:33
Warning: Failed prop type: The prop `utils` is marked as required in `DatePickerWrapper`, but its value is `undefined`.
TypeError: Cannot read property 'date' of undefined
at DatePickerWrapper.PickerBase._this.getValidDateOrCurrent (node_modules/material-ui-pickers/_shared/PickerBase.js:60:23)
Hi @RusinovAnton -- you need to make sure you call addDecorator()beforerequire.context(). This is due to a weirdness in how storyshots implements require.context (#2894). Sorry about the confusion. Thanks for the detailed issue.
Issue details
Storyshots do not run addDecorator in config.js. I have global decorator defined in config.js that wraps any story with component that provides context with theme and utils. My stories work fine but storyshots testing fails because of context not being passed into component that requires it.
Steps to reproduce
Use global decorator in config.js that wraps story in context provider component with context that required by components in stories.
Please specify which version of Storybook and optionally any affected addons that you're running
@storybook/addon-actions
: 3.3.15@storybook/addon-storyshots
: 3.3.15Affected platforms
Screenshots / Screencast / Code Snippets (Optional)
Then I get an error:
Source: https://github.com/dmtrKovalenko/material-ui-pickers/blob/master/lib/src/_shared/WithUtils.jsx#L6
And my test fails because of
Source: https://github.com/dmtrKovalenko/material-ui-pickers/blob/master/lib/src/_shared/PickerBase.jsx#L20
The text was updated successfully, but these errors were encountered: