React - Test

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > React

2 - 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

Advertising

3 - Workbench

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

4 - 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.

5 - watch

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

6 - 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.

7 - Documentation / Reference

Advertising
web/javascript/react/test.txt · Last modified: 2019/06/18 09:30 by gerardnico