-
Notifications
You must be signed in to change notification settings - Fork 6
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
Blog on different types of matchers in Jest for React Testing #242
base: main
Are you sure you want to change the base?
Conversation
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.
LGTM!
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.
@swathynair19 maybe we can get a better image for this, other than that, content looks good
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.
@hulksyed07 Very nicely and concisely explained. Just a few optional nitpicks.
|
||
## What Are Jest Matchers? | ||
|
||
In Jest, matchers are methods that enable you to compare the actual output of your code with the expected outcome. These matchers are used within `expect` statements, and they provide a readable way to express test conditions. |
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.
Nit:
In Jest, matchers are methods that enable you to compare the actual output of your code with the expected outcome. These matchers are used within `expect` statements, and they provide a readable way to express test conditions. | |
In Jest, matchers are methods that enable you to compare the actual output of your code with the expected outcome. These matchers are chained to `expect` statements, providing a readable way to express test conditions. |
expect(component.textContent).toBe('Hello, World!'); | ||
``` | ||
|
||
In this case, `toBe` is a matcher that verifies the actual value matches the expected value exactly. |
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.
In this case, `toBe` is a matcher that verifies the actual value matches the expected value exactly. | |
In this case, `toBe` is a matcher that verifies that the actual value exactly matches the expected value. |
Reads more fluently IMO.
Examples: | ||
|
||
```javascript | ||
import {render, screen} from '@testing-library/react'; |
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.
Nit:
import {render, screen} from '@testing-library/react'; | |
import { render, screen } from '@testing-library/react'; |
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.
@hulksyed07 lets remove this file and update the image to the new one
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.
Have updated it to the new compressed image.
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.
will be good to compress this before merging
What did you do?
Please include a summary of the changes.
Why did you do it?
Why were these changes made?
Screenshots (Please include if anything visual)
Include any relevant screenshots that may help explain the change.