Skip to content

test: replace mocha with jest for unit testing

When we implemented our #199 (closed) automated testing strategy, we didn't quite settle on the unit test framework we are going to use.

The complete discussion: !79 (comment 388227044)

This MR, if merged, will replace mocha with jest.


Decision whether to replace mocha with jest

The mocha and jest are both widely used and supported testing frameworks for JavaScript, both support TypeScrit and neither of them should be a bad choice.

Reasons to use jest:

  • Widely adopted at GitLab (we could use the expertise and helper code)
  • The Jest execution environment provides isolation between test suites1
  • Convention over configuration - runner, DSL, assertions and mocking included

Reasons to keep mocha:

  • Consistency, we have to use mocha for integration test. Using mocha for unit tests will keep the way we test our code consistent.
  • VS Code ecosystem - Vast majority of the extensions2 and the VS Code itself is tested by mocha, new contributors are likely to have experience with writing mocha tests3
  1. https://gitlab.com/pslaughter/compare-mocha-and-jest/

  2. python extension, docker extension, markdown extension

  3. Mocha is the recommended testing framework, but admittedly, most of the VS Code extenions have only integration tests and we use mocha for integration testing.

Edited by Tomas Vik

Merge request reports

Loading