9. Advanced Jest Matchers Flashcards

1
Q

What is a Matcher also known as?

A

An assertion or an expectation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a Matcher represent?

A

A claim that a value will be equal (or not) to something.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens if a Matcher’s claim is not validated?

A

An error is thrown, letting Jest know that the test has failed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens if an error is thrown inside a test?

A

The test fails.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the not matcher?

A

A special matcher that reverses an assertion. It works with any assertion and turns it into its opposite — if assertion without not would pass, assertion with not will fail, and vice versa.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What do the toBe and the toEqual Matchers do?

A

Verify that two values are equivalent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between the toBe and the toEqual Matchers?

A

Two arrays with matching elements are equal (toEqual), but not identical (toBe).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the toBeEqual Matcher?

A

A number Matcher that is similar to toEqual, but assertion still passes if numbers are close but not equal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the toBeEqual Matcher useful for?

A

Assertions involving floating point numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What kind of matchers are toContain and toHaveLength?

A

Array matchers that verify the contents and size of a collection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly