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

Values in collections

There are way more assertion methods available in Jest than I have room to cover in this book. I encourage you to take a look at the Expect section of the Jest API docs: https://facebook.github.io/jest/docs/en/expect.html.

The last two assertion methods I want to go over with you are toHaveProperty() and toContain(). The former tests that an object has a given property while the latter checks that an array contains a given value:

describe('object properties and array values', () => { 
  it('object has property value', () => { 
    expect({ 
      one: 1, 
      two: 2 
    }).toHaveProperty('two', 2); 
 
    expect({ 
      one: 1, 
      two: 2 
    }).not.toHaveProperty('two', 3); 
  }); it('array contains value', () => { expect([1, 2]).toContain(1); expect([1, 2]).not.toContain(3); ...
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