Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support convert shallow wrapper to format compatible with pretty-format and jest-snapshot #541

Commits on Aug 12, 2016

  1. Adding pretty-format compatible ShallowWrapper.json()

    The new `.json()` method convert the shallow node to
    compatible object.
    
    This allow us to use enzyme+shallow with jest-snapshot:
    
    ```
    const Foo = () => <div className="in-foo" />;
    const Bar = ({ value }) => (
      <div className="in-bar">
        <Foo fooProp={value} />
      </div>
    );
    
    const wrapper = shallow(<Bar value={ 'xxx' } />);
    expect(wrapper.json())..toMatchSnapshot();
    ```
    
    will create a snapshot as:
    
    ```
    exports[`example test 1`] = `
    <div className="in-bar">
      <Foo fooProp="xxx" />
    </div>
    `;
    ```
    rodrigopr committed Aug 12, 2016
    Configuration menu
    Copy the full SHA
    532c26a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    105397a View commit details
    Browse the repository at this point in the history