August 2017
Beginner
374 pages
10h 41m
English
Jest offers various ways to test values. Testing values is done using matchers. They have the following structure:
expect(OUTPUT).MATCHER(COMPARISON)
The whole preceding expression is called an assertion. The first part, expect(OUTPUT), returns an "expectation" object. This object offers various matchers (MATCHER), which can be called to compare the output value against a comparison value (COMPARISON). Jest tracks all failing matchers and outputs error messages for you.
In the example test from the previous section, we had the following code:
expect(1 + 1).toBe(2)
In this example, it is:
Read now
Unlock full access