Steve Kinney

Introduction to Testing

Which Testing Framework Should I Use?

You could separate testing libraries into two classes:

  • An assertion library: A library that makes sure that your code does what it expects (or throws an error if it doesn’t). Some examples include Chai, Should.js, Node’s built-in assert module.
  • A test runner: A process that runs through all of your tests and generates reports. Mocha is an example of this. A very basic test running might grep for all of the files that end in *.test.js and execute them using Node.

Some modern testing frameworks (namely: Jasmine, Jest, and Vitest) combine a test runner with an assertion library. So, this distinction probably isn’t terribly important these days, but I think it’s worth calling out. If there was an assertion library that you like more than whatever comes built-in with Jest, you could swap it out with another assertion library and everything should work as expected.

I’m not going to waste your time and make you eat your vegetables and build one from scratch just to prove a point.

Adding Vitest to Visual Studio Code

If you use Vitest and Visual Studio Code, there is a helpful plugin for Visual Studio Code that makes it easy to run your tests from inside your editor. There is also a Visual Studio Code Plugin for Jest.

Last modified on .