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

Add Jest snapshot testing example #683

Merged
merged 1 commit into from
Oct 11, 2016
Merged

Add Jest snapshot testing example #683

merged 1 commit into from
Oct 11, 2016

Conversation

zouxuoz
Copy link
Contributor

@zouxuoz zouxuoz commented Oct 8, 2016

I'm added example to show how use Jest snapshot testing for applications with React Intl. (resolve #681)

@yahoocla
Copy link

yahoocla commented Oct 8, 2016

Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks! 😄

@yahoocla
Copy link

yahoocla commented Oct 8, 2016

CLA is valid!

@zouxuoz
Copy link
Contributor Author

zouxuoz commented Oct 8, 2016

Docs is ready and I'll add it after the pull request is merged.

Copy link
Collaborator

@ericf ericf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zouxuoz this is great, thanks so much for adding this example!

I added some minor comments about code formatting, if you have a chance to resolve them that'd be great.

<AppMain/>
<AppFooter/>
</div>
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make sure the files end with a newline so that Git can track future changes better.

<FormattedMessage {...messages.copyright} />
</div>
</footer>
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add EOF newline.

import { FormattedMessage, defineMessages } from 'react-intl';

const messages = defineMessages({
copyright: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a mix of 2 and 4 space indentation. If you don't mind can you make it consistent throughout the example?

const { counter } = this.state;

return (
<main className="app-main" onClick={this.onClick}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off here.

}
}

export default AppMain;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add EOF newline.

let tree = component.toJSON();

expect(tree).toMatchSnapshot();
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add EOF newline.

let tree = component.toJSON();

expect(tree).toMatchSnapshot();
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add EOF newline.

tree = component.toJSON();

expect(tree).toMatchSnapshot();
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add EOF newline.

ReactDOM.render(
<RootContainer/>,
document.getElementById('root')
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add EOF newline.

);
};

export default createComponentWithIntl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add EOF newline.

@zouxuoz
Copy link
Contributor Author

zouxuoz commented Oct 11, 2016

@ericf sorry for mistakes. I'm resolve it and send pull request with updated eslint for check this mistakes.

@ericf
Copy link
Collaborator

ericf commented Oct 11, 2016

@zouxuoz no worries about the mistakes. I appreciate that you took the time to update the eslint config 😄 Thanks so much for creating this example app and writing up the docs on Jest testing. This will end up serving as my guide when I eventually get around to rewriting React Intl's own tests using Jest.

@ericf ericf merged commit 22079eb into formatjs:master Oct 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jest snapshot testing for application with React Intl (example + docs)
3 participants