Skip to content
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

Storyshots with Storybook 4 for React fails with Angular import. #3754

Closed
swernerx opened this issue Jun 11, 2018 · 6 comments
Closed

Storyshots with Storybook 4 for React fails with Angular import. #3754

swernerx opened this issue Jun 11, 2018 · 6 comments

Comments

@swernerx
Copy link
Contributor

swernerx commented Jun 11, 2018

Framework Loaders tries to load Angular stuff in React environment

After updating from 4.0-alpha.4 to -alpha.9 I see the following happens:

Cannot find module '@storybook/angular/options' from 'loader.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:210:17)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/angular/loader.js:7:16)

This is the not touched Story.test.js which is used to execute the test runner:

import initStoryshots, {
  multiSnapshotWithOptions
} from "@storybook/addon-storyshots"
import { dirname } from "path"

initStoryshots({
  // Delegate to centralized config
  configPath: dirname(require.resolve("edge-storybook")),

  // Storing seperate snapshots for each individual story
  test: multiSnapshotWithOptions({}),

  // Ignore all containers, only snapshot pure components
  // without any app logic or data fetching
  storyKindRegex: /^((?!container).)*$/i
})

Steps to reproduce

Executing jest on the command line.

Please specify which version of Storybook and optionally any affected addons that you're running

  • storybook/react 4.0.0-alpha.9
  • storybook/addon-actions 4.0.0-alpha.9
  • storybook/addon-links 4.0.0-alpha.9
  • storybook/addon-storyshots 4.0.0-alpha.9
  • storybook/addon-viewport 4.0.0-alpha.9
  • jest 23.1.0
@igor-dv
Copy link
Member

igor-dv commented Jun 11, 2018

It will be fixed with #3745

@swernerx
Copy link
Contributor Author

The issue seems relatively obvious after starting studying the current code base:

This is the code from src/frameworkLoader.js:

import loaderReact from './react/loader';
import loaderRn from './rn/loader';
import loaderAngular from './angular/loader';
import loaderVue from './vue/loader';
import loaderHTML from './html/loader';

const loaders = [loaderReact, loaderAngular, loaderRn, loaderVue, loaderHTML];

function loadFramework(options) {
  const loader = loaders.find(frameworkLoader => frameworkLoader.test(options));

  if (!loader) {
    throw new Error('storyshots is intended only to be used with storybook');
  }

  return loader.load(options);
}

export default loadFramework;

Three of these loaders are trying to import @storybook/angular/options:

  • angular
  • html
  • vue

The loader system might need some rework that there is no assumption for frameworks which are not installed or needed.

@igor-dv
Copy link
Member

igor-dv commented Jun 11, 2018

This is a bug that happened recently, and after the merging of #3745, it will be fixed.

@JCMais
Copy link

JCMais commented Jun 13, 2018

@igor-dv may we get a new alpha version with this fix?

@igor-dv
Copy link
Member

igor-dv commented Jun 13, 2018

I assume it will be soon

paradoxxxzero added a commit to Kozea/formol that referenced this issue Jun 19, 2018
@malixsys
Copy link

Any news on the next alpha version? Will it be @storybook/[email protected] ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants