Getting Started - Jest Jest can be used in projects that use webpack to manage assets, styles, and compilation webpack does offer some unique challenges over other tools Refer to the webpack guide to get started
Testing React Apps · Jest See React: Function and Class Components Reminders that with Class components, we expect Jest to be used to test props and not methods directly Now let's use React's test renderer and Jest's snapshot feature to interact with the component and capture the rendered output and create a snapshot file:
Configuring Jest · Jest Jest has default serializers for built-in JavaScript types, HTML elements (Jest 20 0 0+), ImmutableJS (Jest 20 0 0+) and for React elements See snapshot test tutorial for more information
Globals - Jest In your test files, Jest puts each of these methods and objects into the global environment You don't have to require or import anything to use them However, if you prefer explicit imports, you can do import {describe, expect, test} from '@jest globals'
Jest CLI Options The jest command line runner has a number of useful options You can run jest --help to view all available options Many of the options shown below can also be used together to run tests exactly the way you want Every one of Jest's Configuration options can also be specified through the CLI
Testing Web Frameworks · Jest Jest is a universal testing platform, with the ability to adapt to any JavaScript library or framework In this section, we'd like to link to community posts and articles about integrating Jest into popular JS libraries
Expect - Jest Jest adds the inlineSnapshot string argument to the matcher in the test file (instead of an external snap file) the first time that the test runs Check out the section on Inline Snapshots for more info Asymmetric Matchers expect anything() expect anything() matches anything but null or undefined
The Jest Object · Jest - jestjs. io The jest object is automatically in scope within every test file The methods in the jest object help create mocks and let you control Jest's overall behavior It can also be imported explicitly by via import from '@jest globals'