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

[Bug]: Test runner does not run if main storybook config file is a Typescript file in NextJs #21298

Closed
elliotgonzalez123 opened this issue Feb 28, 2023 · 3 comments

Comments

@elliotgonzalez123
Copy link

elliotgonzalez123 commented Feb 28, 2023

Describe the bug

In NextJs, after installing and setting up the storybook test runner, running npm run test-storybook throws the following error in the console...

/Users/{{user}}/Desktop/my-app/.storybook/main.ts: Unexpected token, expected "from"

If you change the main.ts file to main.js, remove the type imports and use module.exports syntax, the test runner runs without a problem.

I've also solved this by adding in a custom .babelrc file in my NextJs project, however this is not ideal as it overrides the new NextJs swc compiler which is necessary for many of NextJs's newest features.

For context, here is a previous issue for a non NextJs project: #17589

To Reproduce

A stackblitz repro can be found here: https://stackblitz.com/edit/github-uriqhe?file=package.json

  1. Setup a fresh NextJs typescript project
  2. Add storybook
  3. Use the typescript example in the docs to setup the config file
  4. Add test runner
  5. Run npm run test-storybook

System

Environment Info:
  System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 18.8.0 - /opt/homebrew/bin/node
    npm: 9.5.1 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 110.0.5481.177
    Firefox: 105.0.3
    Safari: 15.6.1
  npmPackages:
    @storybook/addon-coverage: ^0.0.8 => 0.0.8 
    @storybook/addon-essentials: ^7.0.0-beta.55 => 7.0.0-beta.55 
    @storybook/addon-interactions: ^7.0.0-beta.55 => 7.0.0-beta.55 
    @storybook/addon-links: ^7.0.0-beta.55 => 7.0.0-beta.55 
    @storybook/blocks: ^7.0.0-alpha.8 => 7.0.0-beta.55 
    @storybook/nextjs: ^7.0.0-beta.55 => 7.0.0-beta.55 
    @storybook/react: ^7.0.0-beta.55 => 7.0.0-beta.55 
    @storybook/test-runner: ^0.9.4 => 0.9.4 
    @storybook/testing-library: ^0.0.14-next.1 => 0.0.14-next.1

Additional context

No response

@elliotgonzalez123 elliotgonzalez123 changed the title [Bug]: Test runner does not run if main storybook config file a Typescript file in NextJs [Bug]: Test runner does not run if main storybook config file is a Typescript file in NextJs Feb 28, 2023
@domyen
Copy link
Member

domyen commented Feb 28, 2023

@yannbf @valentinpalkovic Seems like there's a bug when the test runner is combined with next framework in the latest 7.0 beta.

@shilman
Copy link
Member

shilman commented Mar 3, 2023

@elliotgonzalez123 Have you tried upgrading to the next release of the test runner?

@shilman
Copy link
Member

shilman commented Mar 3, 2023

closing as dupe to storybookjs/test-runner#270

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

3 participants