React - Test

List

If you do not want to run your tests inside of a browser, the recommended approach to using mount is to depend on a library called jsdom

Workbench

Testing component framework are called workbench. Example: React - Storybook (Component workbench)

Shallow rendering

shallow rendering lets you render a component “one level deep” and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM.

watch

watch mode. Every time you save a file, it will re-run the tests

Snapshot

With Snapshot testing, we keep a file copy of the structure of UI components. Think of it like a set of HTML sources. Then, after we’ve completed any UI changes, we compare new snapshots with the snapshots that we kept in the file.

A React test renderer that output React components as pure JavaScript objects (No DOM or a native mobile environment dependency) -

It's useful to grab a snapshot of the platform view hierarchy (similar to a DOM tree) rendered by a React DOM or React Native component without using a browser or jsdom.

You can use Jest’s snapshot testing feature to automatically save a copy of the JSON tree to a file and check in your tests that it hasn’t changed

StoryShots is an integration between Storybook and Jest Snapshot Testing.

Documentation / Reference





Discover More
Storybook Actions
React - Storybook (Component workbench)

Storybook is a component workbench where you write story. A story is a single state of your component. Technically, it is a function that returns something that can be rendered to screen. UI component...



Share this page:
Follow us:
Task Runner