0

Having just scoped our first serious React with NodeJs project we're re-evaluating our testing processes. FYI we're traditionally we're an Angular based agency running a Jasmine/Karma etc setup taking out first - excited - steps into ReactJS.

We've had several approaches suggested, generally a Mocha framework based with JsDOM combined with Chai / Mockery / ShouldJS etc.

But newer players of which we've no experience have been suggested like Tape, Jest

Then there's the upcoming Shallow Rendering feature which sounds great but is it stable and usuable with current limitations - is anyone using it yet? there was an interesting read on another thread earlier this year.

Do people generally still use Selenium for React projects or stick with what they can do inside Mocha or are there preferred alternatives? This topic alone seems to have almost marmite advise.

I realise that there are multiple testing routes and 'right tools' for the job, especially when considering things like:

  • state testing
  • event simulation
  • shallow rendering
  • utility testing
  • real DOM
  • etc

So any community insight and experience input into preferred flows would be much appreciated!

2
  • It's "Shallow" not "Swallow" :) Commented Nov 23, 2015 at 15:36
  • good spot, amusing image! Commented Nov 23, 2015 at 15:38

1 Answer 1

1

We've been using jasmine/karma with mocha reporting perfectly fine with React. We found jest to be slow even with a small number of tests.

With React's TestUtils, you can easily test event simulation, e.g.

TestUtils.Simulation.click(element, eventObj);

Testing component state is as easy as:

expect(component.state.myValue).toBe("hello");

Setup isn't that much different as you would with Angular.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, good to know, but it's a shame to hear that about Jest as the automocking feature alone looked promising and, well, I guess I assumed Facebook would have given it the same level of support / headturning status as React enjoyed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.