-
Notifications
You must be signed in to change notification settings - Fork 0
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
test: set up component testing environment with Storybook, Jest, and Chromatic CI job #55
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
dazedbear
changed the title
Component test env
test: set up environment for Storybook, snapshot testing, and Chromatic CI job
Aug 27, 2022
dazedbear
changed the title
test: set up environment for Storybook, snapshot testing, and Chromatic CI job
test: set up component testing environment with Storybook, Jest, and Chromatic CI job
Aug 28, 2022
github-actions bot
pushed a commit
that referenced
this pull request
Aug 28, 2022
## [4.18.1](v4.18.0...v4.18.1) (2022-08-28) ### Testing * set up component testing environment with Storybook, Jest, and Chromatic CI job ([#55](#55)) ([e2a3c39](e2a3c39))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
Based on the testing strategy (#56), add the below changes
Knowledge Transfer / Notes
storybook
main.ts
compatibility issue with nextjs and jestAlthough this storybook official guide tell you that you can use
.storybook/main.ts
instead of.storybook/main.js
. However, it's broken due to the below issue when running Jest testing.I have found a solution yet, so just keep using
.storybook/main.js
for now.css parsing issue in Jest
If your test files contain
import 'src/styles/global.css
like importing pure stylesheet or css modules, Jest cannot parse them correctly, especially when you use tailwind css. This issue can be reproduce when running component snapshot test with@storybook/testing-react
addons.Please refer to the below docs to mock those css files with moduleNameMapper.
react-testing-library issue
Per testing-library/react-testing-library#1038,
@testing-library/react-testing-library
v13 only supports React 18 which introduced react-dom/client. Downgrade to use v12 for a short-term fix.Tailwind CSS style loading issue in storybook
If you configure important in your
tailwind.config.js
, you may encounter the issue that all styles are missing in the storybook.Since we cannot modify the
#root
id of storybook (per storybookjs/storybook#11296),creating a decorator to add a wrapper with id
app
can fix this issue.https://storybook.js.org/docs/react/writing-stories/decorators#wrap-stories-with-extra-markup
Reference
Chromatic
Storybook
Storybook Addons
React Testing
Tailwind CSS
TypeScript
Jest