Evaluate node.js testing frameworks
Goals
The intention of selecting a test framework is to test pure node.js scripts in the data-update-github repository. So far, these scripts include Cindy's new-download-trigger-PR script and Ted’s diffing/merging algorithm.
It hasn't been discussed whether the data merge web interface will be developed in this repository. Since the web UI will very likely be developed using the infusion framework, if UI is a part of this repository, jqUnit from infusion will be the best choice. However, if UI is not part of this repository, pulling in 43M infusion library for testing a few node.js scripts seems an overkill. This evaluation is to determine in the latter case, what's the best choice for testing these node.js scripts.
Requirements
- Can test node.js scripts;
- Support the test of asynchronous code such as Promise;
- Simple and lightweight;
- It would be a bonus if the testing framework supports browser tests, but this is not a must-have.
Comparison
This section compares a few popular Javascript testing framework surfaced via research and recommendations from fluid-work community.
Feature | Infusion jqUnit | Mocha | Ava | Jest |
---|---|---|---|---|
Must have features | ||||
Can test node.js scripts | Yes | Yes | Yes | Yes |
Support the test of asynchronous code such as Promise | Yes | Yes | Yes | Yes |
Documentation | Good | Good | Good | Good |
Size | 42.2M | 3.04M | 272K | 4.34K |
In active development | Developed and supported by our own team | Yes, maintained by volunteers | Yes | Yes, maintained by Facebook |
Community support | Active | Active | Active | Active |
Is open source | Yes | Yes | Yes | Yes |
Popularity | 1.3K weekly downloads | 4.7M weekly downloads | 185.8K weekly downloads | 9.6M weekly downloads |
Bonus but optional features | ||||
Support browser tests | Yes | Yes | No | No |
Support other ES6 features such as import/export | No. Installing esm or babel package may help to support ES6 import/export. | Needs to install esm package or babel to support ES6 import/export. | Needs to specify babel in package.json to support ES6 import/export. See this discussion. | Needs to install a plugin to transform ES6 to commonjs. See this discussion. |
Conclusion
If this repository will contain UI code developed using infusion, the infusion testing framework is the best choice.
Otherwise, Jest seems to be the best choice.
Decision
The decision made at the tech check in meeting on 2020-11-12 is to use infusion node-jqUnit as the testing framework because fluid-testem built around jqUnit is an existing helper for producing the coverage report for combined node.js and browser tests.