The open-source project recently celebrated its major release of Jest 16, which features a new reporter interface and improved CLI output. Developers will also find a treasure trove of new features they might find useful. Now, Jest automatically considers files and tests with the JSX extension, warns about duplicate manual mock files, and has improved its module resolution when moduleNameMapper is used. CLI flags were added, and previously failed tests now always run first, according to a blog post written by Facebook engineer Christoph Pojer.
He also writes, “a –findRelatedTests <fileA> <fileB> CLI option was added to run tests related to the specified files. This is especially helpful as a pre-commit hook if you’d like to run tests only on a specified set of files that have tests associated with them.” Jest will look like this when a test run is interrupted in watch mode.
A big feature of Jest that was first introduced in Jest 14 is its snapshot testing. With Jest 16, the snapshot implementation was complete rewritten, said Pojer. The new version is structured in a way that allows for “easier integration into other test runners and enables more cool integrations like with React Storybook,” he writes.
Several changes were made to the snapshot format, including the removal of function names from snapshots, which were causing numerous issues with different versions of Node. Snapshots are also sorted using natural sort order within a file.
Other top features of this open-source project include its ability to automatically find tests, mock dependencies, and run tests with a fake DOM implementation.
Jest’s GitHub page can be found here.
Wondering where this week’s trending GitHub repositories are? GitHub seems to be taking some time dissecting them. Find today’s trending projects here instead.