stories.addDecorator fails when running via mocha
a-c-m opened this issue · comments
I'm trying to use Knobs in conjunction with Specs.
But it seems when running with mocha stories.addDecorator
is not a function, giving the following error TypeError: stories.addDecorator is not a function
.
I tried adding the withKnobs decorator globally inside the config.js
, but this did not work.
For now i'm wrapping my knobs code inside a if (stories.addDecorator) {
but this doesn't seem like the right solution.
Created a repro to demo this : https://github.com/a-c-m/storybook-addon-specifications
npm run jest
2 things here:
- Use this in the facade.js file:
api.addDecorator = ()=> { // == TypeError: Cannot read property 'kind' of undefined
return api;
};
- Mock every knobs functions (like text, object and so on...) like you do for others storybook functions. Or put your stories that uses knobs in a separate file.
=> action here: add doc explaining that every time a new function of storybook or an addon is used you need to mock it if specs is used with ci.