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

Corrects Name for the Best Flavor of La Croix #9437

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions docs/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ For additional Jest matchers maintained by the Jest Community check out [`jest-e

The `expect` function is used every time you want to test a value. You will rarely call `expect` by itself. Instead, you will use `expect` along with a "matcher" function to assert something about a value.

It's easier to understand this with an example. Let's say you have a method `bestLaCroixFlavor()` which is supposed to return the string `'grapefruit'`. Here's how you would test that:
It's easier to understand this with an example. Let's say you have a method `bestLaCroixFlavor()` which is supposed to return the string `'pamplemousse'`. Here's how you would test that:

```js
test('the best flavor is grapefruit', () => {
expect(bestLaCroixFlavor()).toBe('grapefruit');
test('the best flavor is pamplemousse', () => {
expect(bestLaCroixFlavor()).toBe('pamplemousse');
});
```

Expand Down Expand Up @@ -1055,11 +1055,11 @@ For example, `.toEqual` and `.toBe` behave differently in this test suite, so al

```js
const can1 = {
flavor: 'grapefruit',
flavor: 'pamplemousse',
ounces: 12,
};
const can2 = {
flavor: 'grapefruit',
flavor: 'pamplemousse',
ounces: 12,
};

Expand All @@ -1084,23 +1084,23 @@ If differences between properties do not help you to understand why a test fails

Use `.toMatch` to check that a string matches a regular expression.

For example, you might not know what exactly `essayOnTheBestFlavor()` returns, but you know it's a really long string, and the substring `grapefruit` should be in there somewhere. You can test this with:
For example, you might not know what exactly `essayOnTheBestFlavor()` returns, but you know it's a really long string, and the substring `pamplemousse` should be in there somewhere. You can test this with:

```js
describe('an essay on the best flavor', () => {
test('mentions grapefruit', () => {
expect(essayOnTheBestFlavor()).toMatch(/grapefruit/);
expect(essayOnTheBestFlavor()).toMatch(new RegExp('grapefruit'));
test('mentions pamplemousse', () => {
expect(essayOnTheBestFlavor()).toMatch(/pamplemousse/);
expect(essayOnTheBestFlavor()).toMatch(new RegExp('pamplemousse'));
});
});
```

This matcher also accepts a string, which it will try to match:

```js
describe('grapefruits are healthy', () => {
test('grapefruits are a fruit', () => {
expect('grapefruits').toMatch('fruit');
describe('pamplemousses are healthy', () => {
test('pamplemousses are a fruit', () => {
expect('pamplemousses').toMatch('fruit');
});
});
```
Expand Down