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

[Docs] Add docs for Testing Components #1477

Closed
wants to merge 1 commit into from
Closed

[Docs] Add docs for Testing Components #1477

wants to merge 1 commit into from

Conversation

naoufal
Copy link

@naoufal naoufal commented Jun 1, 2015

This PR adds documentation on how to get started with testing React Native components with Jest.

It stems from #700.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 1, 2015
@brentvatne brentvatne changed the title Add docs for Testing Components [Docs] Add docs for Testing Components Jun 1, 2015
@pwmckenna
Copy link
Contributor

First off, thanks for getting the testing ball rolling! 🍺

I would kind of expect mocks like these to be automatically generated (by react-native cli or jest?). I wouldn't expect people to know that StyleSheet.create is converting styles to handles under the hood, and if you don't understand that, it's not clear why you'd need to c+p these mocks in. Regardless, this is super helpful and much needed.

@brentvatne
Copy link
Collaborator

Agreed, this is a good start. In addition to what we have here, it would be great if we could include instructions as per #700 (comment) for how to do it without mocking out all of the pieces in order to be able to use the shallow renderer.

Could you try this out to see if it works with 0.6.0-rc? If not, let's find a way to make it work 😄


### Transpiling ES6 Code

React Native is written in ES6 and there's a very good chance that your component is it too. So you'll have to make sure to preprocess your source files to ES5 prior to running your tests. You can do this by configuring Jest with a [`scriptPreprocessor`](https://facebook.github.io/jest/docs/api.html#config-scriptpreprocessor-string) like [this one](https://gist.github.com/naoufal/dd8447646fe6f6fbf426).
Copy link
Contributor

Choose a reason for hiding this comment

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

/component is it too/component is too/

@sahrens
Copy link
Contributor

sahrens commented Jun 11, 2015

Hey @brentvatne: want to guide this along and merge it when it's ready?

@brentvatne
Copy link
Collaborator

@sahrens - sure thing

@brentvatne
Copy link
Collaborator

Going to close this because @naoufal is busy at the moment, we can revive when he has more time 😄

@brentvatne brentvatne closed this Sep 10, 2015
@pietropizzi
Copy link

+1 to this. I would really like more documentation on setting up testing ...

@joerodrig
Copy link

+1

1 similar comment
@rops
Copy link

rops commented Jan 13, 2016

+1

@lovelydreamer
Copy link

+1 still an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants