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

Blog on different types of matchers in Jest for React Testing #242

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

hulksyed07
Copy link
Contributor

What did you do?

Please include a summary of the changes.

  • Added a blog on different types of matchers in Jest for React Testing
  • Updated that

Why did you do it?

Why were these changes made?

  • This was missing
  • that needed changes

Screenshots (Please include if anything visual)

Include any relevant screenshots that may help explain the change.

Copy link

@aaditya25052002 aaditya25052002 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@2KAbhishek 2KAbhishek left a 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

Copy link

@radiantshaw radiantshaw left a 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.

Choose a reason for hiding this comment

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

Nit:

Suggested change
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.

Choose a reason for hiding this comment

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

Suggested change
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';

Choose a reason for hiding this comment

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

Nit:

Suggested change
import {render, screen} from '@testing-library/react';
import { render, screen } from '@testing-library/react';

Copy link
Collaborator

@2KAbhishek 2KAbhishek Dec 23, 2024

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

Copy link
Contributor

@swathynair19 swathynair19 Dec 23, 2024

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.

Copy link
Collaborator

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

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.

6 participants