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

Testing #19

Closed
jhollingworth opened this issue Nov 9, 2014 · 10 comments
Closed

Testing #19

jhollingworth opened this issue Nov 9, 2014 · 10 comments
Labels

Comments

@jhollingworth
Copy link
Contributor

@dmitry
Copy link

dmitry commented Jan 22, 2015

Try to build discussion board/forum, I think you can test all the possible cases, that includes:

  • user registration and login
  • threaded routing
  • state for topics and posts
  • pagination
  • offline support
  • caching
  • uploading of an attachment
  • markup encoding/decoding
  • write tests for all those features
  • search engine friendly
  • i18n

And many more stories can be tested.

@jhollingworth jhollingworth added docs and removed mvp labels Jan 26, 2015
@cyrusdavid
Copy link

👍

@dariocravero
Copy link
Contributor

Hi all, I'm putting together a guide on testing marty types here. I think we should merge the relevant bits afterwards :). It uses mocha but could very well be abstracted away from it and other test suites -like tape or jest- could be used then.

@chrisbarmonde
Copy link

One thing I feel is worth mentioning since it's caused me all kinds of problems recently (and this is a React TestUtils problem, not a Marty problem):

When using React's TestUtils.renderIntoDocument, it never ends up "unmounting" the components you pass in because it just "renders" them in a detached DOM node. This, however, creates havoc when you're using containers because the observers are never disposed as a result. So you'll inevitably see really bizarre side-effects while testing stores or something seemingly unrelated further down the line because the container will still be observing and reacting to changes.

I've found you basically have a couple of choices:

  1. Call component.observer.dispose() manually. This assumes that no children inside the component have containers or if you're testing your container directly.
  2. Probably the better option: Call React.unmountComponentAtNode(React.findDOMNode(component).parentNode); once you're done to force all the unmount logic to run on the node and its children. This is necessary if your containered component has children that also have containers to ensure they're also disposed.

I'm not quite sure where this fits into whatever anyone is working on, but there you go.

Edit: I guess I should say there is a third option: Just render <Component.InnerComponent {...props} /> instead of the container.

@oliverwoodings
Copy link
Contributor

https://github.com/QubitProducts/react-test-tree

This might help you with testing. It's a library we wrote at Qubit that
makes testing react components so much simpler.
On 22 May 2015 09:28, "Chris Barmonde" notifications@github.com wrote:

One thing I feel is worth mentioning since it's caused me all kinds of
problems recently (and this is a React TestUtils problem, not a Marty
problem):

When using React's TestUtils.renderIntoDocument, it never ends up
"unmounting" the components you pass in because it just "renders" them in a
detached DOM node. This, however, creates havoc when you're using
containers because the observers are never disposed as a result. So you'll
inevitably see really bizarre side-effects while testing stores or
something seemingly unrelated further down the line because the container
will still be observing and reacting to changes.

I've found you basically have a couple of choices:

  1. Call component.observer.dispose() manually. This assumes that no
    children inside the component have containers or if you're testing your
    container directly.
  2. Probably the better option: Call
    React.unmountComponentAtNode(React.findDOMNode(component).parentNode);
    once you're done to force all the unmount logic to run on the node and its
    children. This is necessary if your containered component has children that
    also have containers to ensure they're also disposed.

I'm not quite sure where this fits into whatever anyone is working on, but
there you go.


Reply to this email directly or view it on GitHub
#19 (comment).

@jhollingworth
Copy link
Contributor Author

@chrisbarmonde I actually just blogged about another library called react-test-tree which makes this process a bit easier:

// instead of
TestUtils.renderIntoDocument(<Foo />);

React.unmountComponentAtNode(React.findDOMNode(component).parentNode)

// you do

let tree = testTree(<Foo />);

tree.dispose();

@jhollingworth
Copy link
Contributor Author

Oh, @oliverwoodings beat me to the punch!

@jmcbee
Copy link

jmcbee commented May 22, 2015

WAHAHA

@chrisbarmonde
Copy link

Hahaha, awesome. I'll check it out. Thanks guys!

@jhollingworth
Copy link
Contributor Author

Just created a repo with examples for v0.10 https://github.com/martyjs/marty-test-examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants