January 2018
Beginner
658 pages
13h 10m
English
Now we can start making some assertions about that sum variable using the expect object. We can pass it into expect to make our assertions, and these assertions aren't going to be new. It's stuff we've already done. We'll expect that the sum variable equals, using toBe, the number 7. Then we'll check that it's a number, using toBeA, inside quotes, number:
it('should async add two numbers', () => { utils.asyncAdd(4, 3, (sum) => { expect(sum).toBe(7).toBeA('number'); });});
Now obviously if it is equal to 7 that means it is a number, but we're using both just to simulate exactly how chaining will work inside of our expect calls.
Now that we have our assertions in place, let's save the file and run ...
Read now
Unlock full access