-
Notifications
You must be signed in to change notification settings - Fork 38
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
add storyshots #388
add storyshots #388
Conversation
Visit the preview URL for this PR (updated for commit e6dba9f): https://pixiv-charcoal-web--pr388-feat-storyshots-w6deqoqx.web.app (expires Mon, 06 Nov 2023 12:53:51 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 314b26d3adca98a761c7e4d9922ebb206ff024a0 |
Size Change: -246 B (0%) Total Size: 585 kB
ℹ️ View Unchanged
|
"resolutions": { | ||
"react-test-renderer": "17.0.2" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
storyshot v7 からは内部で react-test-renderer 18 系を使用するようになっていて charcoal の react 17 との組み合わせでエラーをはいていたのですべての react-test-renderer の version を 17.0.2 で固定した
jest.mock('@react-aria/utils', () => ({ | ||
...jest.requireActual('@react-aria/utils'), | ||
useId: () => 'test-id', | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
react-aria/utils
の useId が実行ごとに代わるので mock
}, | ||
moduleNameMapper: { | ||
...defaultConfig.moduleNameMapper, | ||
'^@charcoal-ui/(.*)$': '<rootDir>/packages/$1/src', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
storyshot を monorepo root で実行してる環境上 @charcoal-ui
の path 解決を jest.config.mjs にあるものとは異なるものを指定したかったので別ファイルにした
めちゃくちゃ mdx 周りで error をはいているのでそれの対応をする
|
この辺で死んでる |
2 の内容find packages -type f -name "*.mdx" | while read -r file; do
mv "$file" "${file%.mdx}.stories.mdx"
done import { transform } from '@babel/core';
import { compileSync } from "@mdx-js/mdx";
export default {
process(src, filename) {
const code = compileSync(src);
const result = transform(code, {
presets: [['@babel/preset-react', { runtime: 'automatic' }]],
filename,
});
return result.code;
},
} transform: {
+ '^.+\\.mdx?$': '<rootDir>/.storybook/transform.mjs',
...defaultConfig.transform,
- '^.+\\.mdx?$': '@storybook/addon-docs/jest-transform-mdx',
}, 2 で動作させるために mdx 拡張子によるエラー内容 Error: Cannot index \`.mdx\` file (\`./packages/tailwind-config/src/docs/borderRadius/index.mdx\`) in \`storyStoreV7: false\` mode.
The legacy story store does not support new-style \`.mdx\` files. If the file above
is not intended to be indexed (i.e. displayed as an entry in the sidebar), either
exclude it from your \`stories\` glob, or add <Meta isTemplate /> to it.
If you wanted to index the file, you'll need to name it \`stories.mdx\` and stick to the
legacy (6.x) MDX API, or use the new store. https://github.com/pixiv/charcoal/pull/401/files#diff-586e4931b7ba3fab6fb8707cf12ddc51f1b9b4a8b80eeacea9e106f9f6796ad3 で意図的に かなり数が少なかったのですが mdx って消していく予定ってありますか? storyshots 的には抜かれていると嬉しい気がします。 |
やったこと
動作確認環境
チェックリスト
不要なチェック項目は消して構いません
備考
.story.mdx
から.stories.mdx
に変更した