mthuret / storybook-addon-specifications

:book: Write tests next to your stories and display their results inside storybook interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Use this in the facade.js file:
api.addDecorator = ()=> { // == TypeError: Cannot read property 'kind' of undefined
     return api;
   };
  1. 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.