question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@storybook/addon-storyshots supports only main.js

See original GitHub issue

Describe the bug

The getMainFile method of the storyshots addon has a hardcoded name for the new configuration style for version 5.3 of main.js. This prevents usage of TypeScript, for example, where the file is main.ts.

You can see the file name here: https://github.com/storybookjs/storybook/blob/76c3f3a6403aeeac6175a4d086c7b35c087f0d52/addons/storyshots/storyshots-core/src/frameworks/configure.ts#L47

It seems the getPreviewFile method correctly supports both JS and TS files.

This results in storyshots failing with storyshots found 0 stories.

If I edit this method to also include TS files, it seems to start working again:

const getMainFile = (configDir: string): string | false => {
  const main = path.join(configDir, 'main.js');
  const mainTS = path.join(configDir, 'main.ts');

  if (isFile(main)) {
    return main;
  }

  if (isFile(mainTS) {
    return mainTS;
  }

  return false;
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
iirojcommented, Feb 5, 2020

Cool, working now!

Although it seems only module.exports works, when using export default causes no configuration to be found.

3reactions
shilmancommented, Jan 23, 2020

So main.ts works – played around with it yesterday – tho AFAICT support for it is entirely accidental. @mrmckeb and I played around for a few minutes and couldn’t figure out WHY it works (that serverRequire is doing something tricky cc @igor-dv ). At any rate, will merge the fix. Thanks @iiroj !!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storyshots Addon | Storybook: Frontend workshop for UI ...
NOTE: if you are using Storybook 5.3's main.js to list story files, this is no longer ... Storyshots addon is currently supporting React,...
Read more >
@storybook/addon-storyshots | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
spring-media/storybook-addon-image-snapshots - Socket.dev
Storybook plugin for taking image snapshots of your stories based on @storybook/addon-storyshots-puppeteer plugin.
Read more >
Storybook Addon StoryShots for Angular 12 - Stack Overflow
As I kept Karma/Jasmine for unit testing (bigger community), Jest is only for snapshots tests with Storybook , so my jest.config.js is under...
Read more >
MIGRATION.md - Storybook - Fossies
New Angular storyshots format; Deprecated Angular story component; New Angular renderer ... Consistent local addon paths in main.js; Deprecated setAddon ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found