Unit Test React with Velocity Example App

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);
  });
  ....
});
1 Like

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.

1 Like

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

Hot off the press :smile:

2 Likes

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

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