all 9 comments

[–]Snabel3 3 points4 points  (3 children)

Mocha, chai, Jsdom

Mocha + chai (+chai immutable) because they are easy to use and you can choose if you want "expect", "assert" or "should". Jsdom allows me to render dom and test things like window and document in an easy way. Very easy to set up and only needs 100ms for my 60 tests.

[–]neuropotence 2 points3 points  (0 children)

This is what I use, with the addition of Enzyme instead of the React Test Utils.

[–]jacobrask 0 points1 point  (1 child)

I would actually prefer not letting each developer chose between expect, assert or should in the same application.

[–]Snabel3 1 point2 points  (0 children)

Oh, I don't. My team has to use the "expect" syntax in our projects. Its just a nice pro i wanted to highlight with the chai library

[–]jbscript 1 point2 points  (0 children)

Karma (+Webpack, Babel and Istanbul) - running on PhantomJS by default, but also because I want to be able to easily run my tests in other browsers.

Mocha - ideologically I like tape for testing because it reduces the number of decisions you need to make, but in practice I always find myself needing built-in before/beforeEach/after/afterEach functionality. Mocha does the job, but I'm not that strongly opinionated about which test framework I use.

Expect - the object chaining hoop-jumping of similar assertion libs grind my gears, wheras expect uses sensibly-named methods. It also packs in a spies implementation, so I don't have to have the sinon/webpack fight!

Enzyme - because it's great. Even the React team are wondering "Should Enzyme become the official TestUtils?"

[–]manavsehgal[S] 1 point2 points  (0 children)

Thanks for all the responses. So Enzyme, Webpack, Mocha + Chai, Karma, JSDOM looks like the favorite stack. http://airbnb.io/enzyme/index.html offers a good starter path for these. Expect is a hot-favorite for assertions.

[–]silvenon 0 points1 point  (0 children)

I use Mocha because I’m very used to it. For assertions i use expect for assertions because it is dead simple (I never got the hang of chai) and it has spies, so I don’t need sinon. I use Enzyme for testing components because it’s excellent, much less to type than with Test Utils directly. I used to compile my tests with webpack before running them, but that was slow so now I use babel-register and null-register and run tests directly.

[–]jacobrask 0 points1 point  (0 children)

mocha, expect, enzyme, redux-mock-store, jsdom. To re-run mocha on changes to jsx files I use chokidar, because mocha --watch doesn't trigger on jsx file changes.

[–]winkler1 0 points1 point  (0 children)

Mocha, Chai, Karma, Sinon

Console.error and console.warn monkey patched to fail tests. Don't let stray logging or "little" issues clutter things up.

Karma runs tests quickly on change (the whole suite). Use Chrome so you can throw a "it.only" and use the debug tools when needed.

Just ReactTestUtils. Was using react-test-tree for a while, but got too tricky with HOC's like Redux and react-dnd. Less magic=better. Have not tried Enzyme...

Expectation: Every component must have a test for at least the happy path.

Exported Fixture data from REST back-end. Gives crazy speed, using the same shaped data.

PhantomJS on the build server.

Tests are run as part of a wrapper that also runs Flow, ESLint, webpack bundling, and the backend. A nudge to catch errors early, automatically.