Bundle react-test-renderer with AVA
See original GitHub issueIs there any reason why user has to manually import react-test-renderer
and render their React tree “by hand”?
import test from 'ava';
import React from 'react';
import renderer from 'react-test-renderer';
test('snapshots', t => {
const tree = renderer.create(<h1>Test</h1>).toJSON();
t.snapshot(tree);
});
We could bundle react-test-renderer
and that test would become:
import test from 'ava';
import React from 'react';
test('snapshots', t => {
const tree = <h1>Test</h1>;
t.snapshot(tree);
});
…which is cleaner and nicer, imo.
Main reason for it is to also allow magic assert to do diffing on snapshots. Because trees in snapshots are not shallowly rendered (full trees are saved instead), we can’t use react-element-to-jsx-string
module, so we need react-test-renderer
inside AVA either way.
What do you think?
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
ReactJS : setup ava for testing react components
Ava.js is a futuristic test runner, which runs your tests concurrently. This will force you to write tests without depending on a global ......
Read more >Test Renderer - React
This package provides a React renderer that can be used to render React components to pure JavaScript objects, without depending on the DOM...
Read more >Testing the Bejeezus out of React Native Apps with AVA
This article shows you how to use AVA to test your React Native app. It covers all the 3rd party libraries required to...
Read more >Testing React Native components in Node with react ... - Medium
The react-test-renderer package makes it convenient to test components outside of their native environment (e.g. on an iOS/Android device ...
Read more >Testing React Components with AVA - Semaphore CI
We'll connect our React components to the Redux store, test them using AVA and Airbnb's Enzyme, and see how React makes it easy...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What about projects that use JSX with another tool than React (Inferno, Preact, Snabbdom, …)?
Closing this, since the issue is now resolved.