Unit Test React with Velocity Example App


#1

I’ve put together a small repo that shows how to test a React app with Velocity and Jasmine unit tests. Surprisingly the workflow is quite nice! (note Meteor 1.2 will run these much faster).

https://github.com/AdamBrodzinski/react-meteor-tests

describe("Counter Component", function() {
   ....

  it("should have default foo prop", function() {
    renderWithProps({});
    expect(component.props.foo).toBe(true);
  });

  it("should toggle hidden state", function() {
    renderWithProps({});
    component.toggleHidden();
    expect(component.state.isHidden).toBe(true);
  });
  ....
});

[SOLVED] What is a good way of testing React component callbacks to parent components?
#2

Wow, this looks really great and is a wonderful benefit of building your app with React.

It would be super sweet to have an article so that I can link people to it; although I guess this forum post could be it.


#3

Thanks! If all goes well I’ll have a blog post ready this weekend!


#4

Hot off the press :smile:


#5

@sashko would you like me to add tests to the React Leaderboard example app? Or would that add too much overhead to the example?


#6

Let’s not do that yet. Literally today we are working on cleaning up the examples, let’s see where they land first.