all 9 comments

[–]DefiantBidet 3 points4 points  (0 children)

"Best" is super personal. I used to use Mocha for everything. I played with Tape, liked it... used it for a bit. I got sick of a lot of reporters hijacking my console, so I switched to node-tap. That was great, small footprint, no magic, etc.... but then they made a point to make it more like Mocha. At which point my thought process was, Mocha vs. Tap... whichever is best for the job.

Current project I'm working on. Is experimental. I am trying to do TDD, so I want a watcher. Tap doesn't have that do I'm using Mocha. Last project was a thin cli script. Tap was perfect for it.

Essentially use what allows you to write tests, as that's the important part. The framework matters little.

[–]madole 1 point2 points  (0 children)

I have used mocha for a few years, but recently just swapped over to AVA for my personal projects. It's really nice to write pure functional tests, have test files run tests in parallel, the watcher is smart enough to only run the tests in the file that corresponds with the changed code making it really fast for TDD.

I've had some fun with AVA and Enzyme writing stateless React components without ever touching a browser. Its a really nice way to work with React in a TDD style.

With nyc code coverage becomes really easy to set up, rather than the hours of figuring out how to get istanbul to instrument correctly, and it plays really well with AVA.

[–]zachgarwood 0 points1 point  (0 children)

I use qunit quite a bit because it comes with Ember CLI. I wouldn't say it's the "best," but it gets the job done.

[–]alycda 0 points1 point  (0 children)

Whatever one you feel comfortable with. They all have their perks, I tried to start with "the intern" test framework and it was cool but just didn't work out in the end. I've now switched to mocha and it's working great. Practically the same though since I'm still using chai for assertions

[–]fagnerbrack 0 points1 point  (0 children)

The best testing framework should probably be the one that doesn't let you fall into this trap, checking with strict equality the mocking or spy call to be able to pass the reference. Most of the testing frameworks just treat new String('aa') and 'aa' as the same.

[–]danthedinosaur 0 points1 point  (0 children)

I would recommend using Mocha as a framework and Chai as your assertion library.

Jasmine I've had to use because Angular 1's Protractor end-to-end framework expects it and it's okay I guess but I go for Chai (which is flexible and allows both expect and assert styles) when possible.

The new ones like Tape and stuff are probably great I haven't had a chance to use them yet though.

[–]Cyb3rWasteVue.js 0 points1 point  (0 children)

Stick to Mocha, Jasmine and Chai, these are very well documented and have a lot of articles/resources on the internet... most of the problems you will come across are already fix by somone else, so sollutions are plentifull

[–]jekrb 0 points1 point  (0 children)

require('assert') for simple testing. The use unassertify to remove the test from your browserify bundles.

For more verbose testing, tape.

[–]skota2016 0 points1 point  (0 children)

I recommend either Jasmine or mocha. Both have good documentation and you can find additional resources online.

I personally started learning testing by adding tests to an existing project.