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

Addon-docs: Add jest-transform.js to convert .mdx => .js for storyshots #7330

Closed
wants to merge 3 commits into from
Closed

Addon-docs: Add jest-transform.js to convert .mdx => .js for storyshots #7330

wants to merge 3 commits into from

Conversation

danielknell
Copy link

Issue: #7223

What I did

Wrote a jest transform for mdx files.

How to test

add the following to your jest config:

{
  "transform": {
    "^.+\\.[tj]sx?$": "babel-jest",
    "^.+\\.mdx?$": "@storybook/addon-docs/jest-transform",
  }
}

and run jest in a project with storyshots setup and MDX stories.

might need some additional work for things like vue/etc of which i am clueless.

@vercel
Copy link

vercel bot commented Jul 6, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://monorepo-git-fork-danielknell-jest-transform.storybook.now.sh

@vercel vercel bot temporarily deployed to staging July 7, 2019 07:44 Inactive
@stale stale bot added the inactive label Jul 28, 2019
@stale stale bot removed the inactive label Jul 29, 2019
@storybookjs storybookjs deleted a comment from stale bot Jul 29, 2019
@ndelangen
Copy link
Member

Wow awesome first contribution @danielknell !

@shilman are you looking at merging this?

@shilman
Copy link
Member

shilman commented Jul 29, 2019

@ndelangen absolutely. the source repo seems to have disappeared, so i'll need to resurrect the changes in a new branch & test them. but this is def going in.

@shilman shilman self-assigned this Jul 30, 2019
@danielknell
Copy link
Author

danielknell commented Jul 30, 2019

git fetch origin pull/7330/head:pr7330

@shilman shilman changed the title feat(addon-docs): add jest-transform.js to convert .mdx => .js for storyshots Addon-docs: Add jest-transform.js to convert .mdx => .js for storyshots Aug 31, 2019
@shilman shilman modified the milestones: 5.2.0, 5.3.0 Aug 31, 2019
${result}
`;

return babel.process(result, filename, config, options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't work with custom babel-jest transformer (like the one we have in our own repo), you may want to borrow the approach from injectFileName instead

@Hypnosphi
Copy link
Member

jest-transform sounds too generic, let's rename to jest-transform-mdx maybe?

@aendra-rininsland
Copy link

What's blocking this from merging? Is there any way I could help? I've started writing stories in MDX and not being able to snapshot test them is blocking me on a few things.

@shilman
Copy link
Member

shilman commented Sep 13, 2019

@Aendrew This is going into 5.3 and we're in the process of releasing 5.2 right now. We'll work through the 5.3 PRs as soon as that's out. I'll let you know if there's anything that can expedite it after 5.2 is out. Thanks!

@danielknell
Copy link
Author

As a stop gap if you save the transform file locally in the project and change the reference to a relative path you can use it now, that's what my project is doing.

See the linked issue for details.

@aendra-rininsland
Copy link

Just a note, I'm intermittently running into abbr/deasync#55 when using this code in Node 10.16.2 on OS X 10.14.6, I think it's due to deasync-promise.

You can remove the dependency on deasync-promise entirely by using mdx.sync.

@B3Kay
Copy link

B3Kay commented Sep 24, 2019

Cannot wait for this!

@ndelangen
Copy link
Member

replaced with this PR: #8189

Because this PR is without a repo now for some reason.

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

Successfully merging this pull request may close these issues.

6 participants