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 rudimentary test renderer #6944

Merged
merged 1 commit into from
Jun 1, 2016
Merged

Conversation

sophiebits
Copy link
Collaborator

No description provided.

@zpao
Copy link
Member

zpao commented Jun 1, 2016

Nothing exposed and we can iterate before we support anything so go go go.

@sophiebits sophiebits merged commit 50982ce into facebook:master Jun 1, 2016
*
* @param {ReactComponent} componentInstance The instance to mount.
* @param {number} rootID ID of the root node.
* @param {number} containerTag container element to mount into.
Copy link
Contributor

Choose a reason for hiding this comment

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

extra jsdoc blocks (rootId and containerTag)

@sophiebits
Copy link
Collaborator Author

cc @cpojer

@cpojer
Copy link
Contributor

cpojer commented Jun 2, 2016

Awesome. We'll hook this up with snapshot testing over the next two weeks and make a Jest release in about 1.5 weeks from now and also post a nice blog post about snapshot testing. This is gonna be great for react-dom, react-native and any other render target testing.

@cpojer
Copy link
Contributor

cpojer commented Jun 2, 2016

Also cc @thejameskyle@spicyj is adding a field to typecheck whether this is a test render instance, in pretty-format we can then do:

// Jest:
expect(rendered).toMatchSnapshot();

// pretty-format:
if (value.$$typeof == 'react.test-render') {
  formatAsJSXLike(value.toJSON);
}

this is gonna be great.

@sophiebits
Copy link
Collaborator Author

Let's hold off on any public announcement until we solidify the APIs and try it at Facebook some.

@cpojer
Copy link
Contributor

cpojer commented Jun 2, 2016

Yep, that is the plan but @gaearon tweeted about it already!

To everyone: please give us two weeks until we can better explain what this is, to show how it works and so we can explain which API guarantees we are providing in React and in Jest.

@bruderstein
Copy link

Have I understood correctly that this cannot be used together with the DOM renderer, because of the injection? i.e. once your node process has required this, then using both this and (for instance) TestUtils.renderIntoDocument in the same test file isn't possible, as GenericComponentClass and others have already been injected?

Or am I missing something?

(+1 on having a $$typeof or similar so we can identify the JSON and pretty print in assertion libraries, I tripped over this building support into unexpected-react)

@zpao zpao added this to the 15-next milestone Jun 6, 2016
zpao pushed a commit to zpao/react that referenced this pull request Jun 8, 2016
zpao pushed a commit that referenced this pull request Jun 14, 2016
@zpao zpao modified the milestones: 15-next, 15.2.0 Jun 14, 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.

5 participants