bahmutov / snap-shot

Jest-like snapshot feature for the rest of us, works magically by finding the right caller function
168 stars 3 forks source link

How to make work with JSX #24

Closed bahmutov closed 7 years ago

bahmutov commented 7 years ago

If the test code has JSX, does not work, for example see https://github.com/bahmutov/snap-shot-jest-test/blob/master/Link.test.js - crashes on line <Link page="http://www.facebook.com">Facebook</Link>

import React from 'react';
import Link from './Link';
import renderer from 'react-test-renderer';
import snapshot from 'snap-shot'
test.skip('Link changes the class when hovered', () => {
  // snapshot does not know how to handle JSX
  const component = renderer.create(
    <Link page="http://www.facebook.com">Facebook</Link>
  );
  let tree = component.toJSON();
  snapshot(tree)
});