-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
Is 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?