Comments (10)
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.
from marty.
👍
from marty.
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.
from marty.
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:
- Call
component.observer.dispose()
manually. This assumes that no children inside the component have containers or if you're testing your container directly. - 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.
from marty.
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" [email protected] 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:
- Call component.observer.dispose() manually. This assumes that no
children inside the component have containers or if you're testing your
container directly.- 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).
from marty.
@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();
from marty.
Oh, @oliverwoodings beat me to the punch!
from marty.
WAHAHA
from marty.
Hahaha, awesome. I'll check it out. Thanks guys!
from marty.
Just created a repo with examples for v0.10 https://github.com/martyjs/marty-test-examples
from marty.
Related Issues (20)
- Cannot read property '0' of undefined HOT 2
- Does the GitHub fetch library have to be used in HTTP Sources? HOT 3
- Server side fetches do not calculate content-length header HOT 6
- webpack, babel, karma & marty v0.9.17 problem with requiring react HOT 5
- I can't get Marty session storage to persist between tabs or Marty localStorage to work at all! HOT 8
- Running headless tests with PhantomJS as a 'browser' fails HOT 2
- Return error in locally HOT 5
- Optionally require `es6-promise` and `isomorphic-fetch` HOT 2
- not properly escaping "</script>" in app state dehydration HOT 2
- test-utils component specs throw on undefined `document` element HOT 10
- Performance Implications? HOT 2
- React.createElement called on each store change
- Consider reversing order in this.handlers HOT 4
- Application.renderToString performance HOT 5
- Application.RenderToString hangs when fetch result returns the value false. HOT 1
- no-iisue HOT 1
- Fetch state in a container based on the result of another fetch HOT 1
- Support React 0.14.0 HOT 6
- Update Docs HOT 2
- How awesome this project has been! HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marty.