Giter Site home page Giter Site logo

Testing about marty HOT 10 CLOSED

martyjs avatar martyjs commented on July 28, 2024
Testing

from marty.

Comments (10)

dmitry avatar dmitry commented on July 28, 2024

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.

cyrusdavid avatar cyrusdavid commented on July 28, 2024

👍

from marty.

dariocravero avatar dariocravero commented on July 28, 2024

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.

chrisbarmonde avatar chrisbarmonde commented on July 28, 2024

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.

from marty.

oliverwoodings avatar oliverwoodings commented on July 28, 2024

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:

  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).

from marty.

jhollingworth avatar jhollingworth commented on July 28, 2024

@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.

jhollingworth avatar jhollingworth commented on July 28, 2024

Oh, @oliverwoodings beat me to the punch!

from marty.

jmcbee avatar jmcbee commented on July 28, 2024

WAHAHA

from marty.

chrisbarmonde avatar chrisbarmonde commented on July 28, 2024

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

from marty.

jhollingworth avatar jhollingworth commented on July 28, 2024

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

from marty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.