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] Support mdx #36

Closed
bodograumann opened this issue Feb 2, 2022 · 7 comments
Closed

[Feature Request] Support mdx #36

bodograumann opened this issue Feb 2, 2022 · 7 comments
Labels
feature request New feature or request

Comments

@bodograumann
Copy link
Contributor

All my stories are in mdx format.
It would be great if I could run all the play function tests therein automatically and during the ci pipeline.

I tried using --stories-json, but the runner still did not find any tests...

@shilman shilman added the feature request New feature or request label Feb 3, 2022
@shilman
Copy link
Member

shilman commented Feb 3, 2022

@bodograumann is there a stories.json file when you browse <your_sb_url>/stories.json? that should be a valid workaround for MDX stories, so if it's not working I'd love to get to the bottom of it.

@bodograumann
Copy link
Contributor Author

Indeed, @shilman, I have enabled the buildStoriesJson feature flag to get the stories.json (not storyStoreV7 though).
There was a change in the output, but still no tests were found apparently.

Without --stories-json:

> npm run storybook:test           

> my-app@2.4.0 storybook:test
> test-storybook

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /home/bodo/my-app
  323 files checked.
  testMatch: **/*.stories.[jt]s?(x) - 0 matches
  testPathIgnorePatterns: /node_modules/ - 323 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches

With --stories-json:

> npm run storybook:test

> my-app@2.4.0 storybook:test
> test-storybook -- --stories-json

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /home/bodo/my-app
  401 files checked.
  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 8 matches
  testPathIgnorePatterns: /node_modules/ - 401 matches
  testRegex:  - 0 matches
Pattern: --stories-json|--config|/home/bodo/my-app/node_modules/@storybook/test-runner/test-runner-jest.config.js - 0 matches

@yannbf
Copy link
Member

yannbf commented Feb 3, 2022

Hey @bodograumann is there a chance you're using v0.0.1? If so, can you try v0.0.2-next.4 and run the same command?

@yannbf
Copy link
Member

yannbf commented Feb 3, 2022

BTW thank you a lot for trying this library! It's incredible how active you are around the storybook community and we really appreciate that!!

@bodograumann
Copy link
Contributor Author

Thank you for saying that, @yannbf ☺️

You were right with your guess. I had, kind of blindly, followed the installation instructions and of course gotten only version 0.0.1.
With 0.0.2-next.4 and using --stories-json the tests are all run ❤️.

I am leaving this ticket open for first-level mdx support, but for now this is already a good solution for us. 🚀

@danspratling
Copy link

danspratling commented May 31, 2022

Are there any updates on this? I'm trying to test (local) stories from MDX files (accessibility & interactions)

The tests run within storybook fine, but don't run using test runner

I'm currently on v0.1.1

When I enable the buildStoriesJson flag in storybook/main.js it this throws an error when running storybook - without it I always get the above no stories found error

.../node_modules/file-system-cache/lib/common/Util.js:66
            throw new Error(`Failed to read cache value at: ${path}. ${error.message}`);

EDIT: I found a solution

In my case, this was because the storybook build was erroring.

Once I followed the instructions in this issue, it was fixed

storybookjs/storybook#18094

@yannbf
Copy link
Member

yannbf commented Aug 17, 2022

Hey peeps! I'm closing this ticket given that direct MDX support is not in our plans. You can achieve your tests by using --stories-json or --index-json (if you're using newer versions of test-runner). Thank you!

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

No branches or pull requests

4 participants