Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Documentation is conflicting? #66

Open
leetercola opened this issue Sep 12, 2017 · 1 comment
Open

Documentation is conflicting? #66

leetercola opened this issue Sep 12, 2017 · 1 comment

Comments

@leetercola
Copy link

is it .storybook/__mocks__/facade.js or .storybook/facade.js or both?

import { storiesOf } from '@kadira/storybook' < --- this is the depreciated version? new version should be just @storybook

Should this add snapshot results to the storybook spec page or what's the point?

@mrlubos
Copy link

mrlubos commented Feb 27, 2018

Yes, the whole documentation is quite outdated @leetercola.

I guess you figured it out by now, but for future reference, importing storiesOf depends on your framework as of Storybook 3.4.0-alpha.9.

import { storiesOf } from '@storybook/react';
import { storiesOf } from '@storybook/vue';
import { storiesOf } from '@storybook/angular';

As for mocking modules, __mocks__ is one of the directories Jest will search for mocks. So if you have in root modules test.js and facade.js like this.

facade.js

export const CONSTANT = 'hello';
test.js

import CONSTANT from './facade';

console.log(CONSTANT); // <- hello

You can place a mocked facade.js file inside __mocks__.

facade.js

export const CONSTANT = 'mocked';

When Jest runs your tests, this is what will happen in test.js.

test.js

import CONSTANT from './facade'; // mocked from __mocks__ because of jest.mock() in config

console.log(CONSTANT); // <- mocked

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants