Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature: Unit testing#42

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ayshiff wants to merge4 commits intodraftbit:master
base:master
Choose a base branch
Loading
fromayshiff:feature/unit-testing

Conversation

@ayshiff
Copy link
Contributor

@ayshiffayshiff commentedDec 7, 2020
edited
Loading

I felt thatavatar-generator needed some testing.
This PR setup the testing environment usingbs-jest/bs-react-testing-library and add some tests here and there.
It's not much, but it's always better to have some tests.

Testing a ReasonReact component

bs-react-testing-library + bs-jest

I created a wrapper component calledTestId which pass the data-testid (used byreact-testing-library) props to its children.
As Reasondoesn’t support using props with dashes.
I don't really like this method as it requires addingextra code to the source files, but it works.

1 - Wrap your component using theTestId Wrapper inside your source file
2 - Render your component inside your test file
3 - You can query your elements using yourdata-testid or using other queries (queryByLabelText,queryByTitle,queryByText...) andfire some events.

Testing a Reason function

bs-jest

NOTE: I had to add ababel.config.js file and atransformIgnorePatterns options in thejest configuration because of the es6 modules (related issue).
I also had to add the presetbabel-preset-gatsby because gatsby returned an error during the compilation if I did not specify it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@ayshiff

[8]ページ先頭

©2009-2025 Movatter.jp