I would like to kickstart implementing a JavaScript testing framework in my project. Which one should I use? Mocha or Karma? Or is there something better?
I am surprised no body mentioned Jest. Jest is probably the most complete framework that you can find out there. Comes with doms which is great for front-end. Comes with spies and mocks which is essential for unit testing. Comes with code coverage which is awesome.
I've worked with the following:
And some assert libs such as chaijs, expect.js, etc.
Karma is a testrunner (like wallaby).
Testframeworks are (for example):
I'm new to testing too, but I now two things:
Mocha works everywere. It's the universal tool.
Tape is easy to use and highly recommented.
I would start with mocha, but only because I did myself and never regretted it. I still use Mocha with chai.expect(). For front end I use Karma in addition, but that came after a while.
I assume you know about TDD? If not, do it in this direction (IMO):
HOWEVER: Once you've configured Karma for a project and it works, your workflow will go faster.
Dong Nguyen
Web Developer
Shajan Jacob
Software Engineer | Full-Stack Web Developer
I was using mocha for a long time. I just moved to
jestand found its excellent.