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

test(core): setup @testing-library/jest-dom and add component test for Box #278

Merged
merged 3 commits into from
Aug 10, 2023

Conversation

MH4GF
Copy link
Contributor

@MH4GF MH4GF commented Aug 8, 2023

Description

This PR will set up @testing-library/jest-dom to be able to use toBeInTheDocument(), etc. in component testing.

Motivation

I was going to try this issue #256, but first I wanted to be able to easily assert that existing usage was not broken.

How was it tested

As a sample test, I have added the test code for the Box component.
If this plan is acceptable, I will expand the test code for other components 👍🏻

@vercel
Copy link

vercel bot commented Aug 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kuma-ui-website ❌ Failed (Inspect) Aug 8, 2023 10:55pm

@changeset-bot
Copy link

changeset-bot bot commented Aug 8, 2023

🦋 Changeset detected

Latest commit: 664ad09

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@kuma-ui/core Patch
@kuma-ui/babel-plugin Patch
@kuma-ui/compiler Patch
@kuma-ui/next-plugin Patch
next-app-router Patch
next Patch
react-vite-example Patch
webpack Patch
website Patch
@kuma-ui/vite Patch
@kuma-ui/webpack-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 8, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 664ad09:

Sandbox Source
React Configuration
React Typescript Configuration

@MH4GF MH4GF changed the title setup jest dom test(core): setup @testing-library/jest-dom and add component test for Box Aug 8, 2023
@MH4GF MH4GF marked this pull request as ready for review August 8, 2023 01:01
Comment on lines +5 to +9
declare module "vitest" {
interface Assertion<T>
extends jest.Matchers<void, T>,
TestingLibraryMatchers<T, void> {}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@kotarella1110 kotarella1110 left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM 🎉

@kotarella1110
Copy link
Member

@MH4GF Please add a changeset. You can add it from the following link 🙏🏻

スクリーンショット 2023-08-08 22 55 55

@MH4GF
Copy link
Contributor Author

MH4GF commented Aug 8, 2023

@kotarella1110 Oh, I added it! 664ad09

@MH4GF MH4GF requested a review from kotarella1110 August 8, 2023 23:07
@poteboy
Copy link
Member

poteboy commented Aug 10, 2023

@MH4GF
Thanks for the PR! Could you modify the tests in spacer.test.tsx to use toHaveStyle instead of calculating the style from getComputedStyle, especially now that we have an extended matcher from testing-library/jest-dom?

@MH4GF
Copy link
Contributor Author

MH4GF commented Aug 10, 2023

@poteboy Of course! But since the scope of this PR is larger, can I use a different PR?
In addition to modifying spacer.test.tsx, I also wanted to move the cleanup() to vitest.setup.ts:

beforeEach(() => {
cleanup();
});

@poteboy poteboy merged commit a03add5 into kuma-ui:main Aug 10, 2023
@github-actions github-actions bot mentioned this pull request Aug 10, 2023
@MH4GF MH4GF deleted the setup-jest-dom branch August 15, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants