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

[Feature Request] Make test-runner work with Svelte CSF. #262

Open
jwerre opened this issue Feb 8, 2023 · 5 comments
Open

[Feature Request] Make test-runner work with Svelte CSF. #262

jwerre opened this issue Feb 8, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@jwerre
Copy link

jwerre commented Feb 8, 2023

Describe the bug

The test runner doesn't work with Svelte CSF which is essential for making Svelte components with Storybook.

Steps to reproduce the behavior

  1. Checkout this repo
  2. git checkout csf3
  3. npm test - see tests pass
  4. git checkout svelte
  5. npm test - see tests fail

Expected behavior

This repo has the same story, one written in CSF3 while the other is written in Svelte CSF. The CSF3 story passes but the Svelte story fails

Screenshots and/or logs

$test-storybook

importing from @storybook/store is deprecated and will be removed in 8.0, please import canvas related modules from @storybook/preview-api
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/jw/Work/storybook_playground
  4 files checked.
  testMatch: /Users/jw/Work/storybook_playground/stories/**/*.mdx, /Users/jw/Work/storybook_playground/stories/**/*.stories.@(js|jsx|ts|tsx|svelte), /Users/jw/Work/storybook_playground/.storybook/*.stories.svelte - 0 matches
  testPathIgnorePatterns: /node_modules/ - 4 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches

Environment

  • OS: 13.1
  • Node.js version: 18.13.0
  • NPM version: 8.19.3
@JReinhold
Copy link
Contributor

I don't know all the details regarding story indexers and the test runner, but there's a chance this could be implemented more generally, if the test-runner supported users' custom story indexers - like the one from addon-svelte-csf.

@JReinhold
Copy link
Contributor

It turns out this currently works, but requires the --index-json flag. I tested it out in your repro and it correctly passed one test. npm run test-storybook -- --index-json.

Could you test this out in your own more complex setup and let us know if it works there too?

@jwerre
Copy link
Author

jwerre commented Feb 9, 2023

I just tried this locally and it worked! I'll push this up to my CI today and check there.... will be in touch.

@JReinhold
Copy link
Contributor

Using the index.json mode has its limitations, mainly that watch mode isn't supported, because it doesn't run directly on the filesystem but rather on the story index, so there's no way to know when something has changed.

We've looked into this, and the way custom story indexers (like addon-svelte-csf) needs to be implemented makes it very hard to get around these limitations. So for now, this is the workaround we recommend. This might change in the future, we're considering improving the support for custom story indexers in Storybook core.

@jwerre
Copy link
Author

jwerre commented Feb 9, 2023

It's not a big deal, since, if you're working locally, the test run in the Interactive panel on save. I was mostly looking for something to run my tests in CI which this solves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants