Skip to Content
React 16 Tooling
book

React 16 Tooling

by Adam Boduch, Christopher Pitt
April 2018
Intermediate to advanced content levelIntermediate to advanced
298 pages
6h 34m
English
Packt Publishing
Content preview from React 16 Tooling

Basic equality

You can assert that two values are the same by using the toBe() expectation method:

describe('basic equality', () => { 
  it('true is true', () => { 
    expect(true).toBe(true); 
    expect(true).not.toBe(false); 
  }); 
 
  it('false is false', () => { 
    expect(false).toBe(false); 
    expect(false).not.toBe(true); 
  }); 
}); 

In the first test, you're expecting true to equal true. Then, you're negating this expectation in the next line using the .not property. If this were a real unit test, you wouldn't have to prove the opposite of an assertion that you've just made like this—I'm doing this to illustrate some of your options.

In the second test, we're performing the same assertions but with false as the expectation value. The toBe() method uses strict ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro React 16

Pro React 16

Adam Freeman

Publisher Resources

ISBN: 9781788835015Supplemental Content