https://github.com/learosema/javascript-tests
A comparison of test frameworks in javascript
https://github.com/learosema/javascript-tests
Last synced: 4 days ago
JSON representation
A comparison of test frameworks in javascript
- Host: GitHub
- URL: https://github.com/learosema/javascript-tests
- Owner: learosema
- License: mit
- Created: 2018-06-28T09:53:29.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-30T17:23:48.000Z (almost 8 years ago)
- Last Synced: 2025-08-10T20:40:15.337Z (11 months ago)
- Language: JavaScript
- Size: 282 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# javascript-tests
A comparison of test frameworks in javascript
In this repo, I am going to experiment with several test frameworks that are available in JavaScript and give a quick overview.
On my machine, I am using the current LTS version of node in a Windows environment, but other platforms with node versions >= v8.11.3 should work fine.
For bundling and transpilation, I'm using `babel` and the [parceljs bundler](https://parceljs.org).
## running the example
Type `npm install` to install the dependencies and then type `npm start`.
Alternatively, you can also just browse to https://terabaud.github.io/javascript-tests/ and hit F12.
## What are we going to test?
For now, we are going to test a pretty boring [math.js](https://github.com/terabaud/javascript-tests/blob/master/src/math.js) library.
As a pretest step, linting is done via [standardjs](https://standardjs.com).
## Testing
Type `npm test` to run all the tests.
### tape
[tape](https://github.com/substack/tape) is a simple testing framework that produces [TAP](http://testanything.org/) output, a standardized protocol for automated tests.
To use tape in your project, install [tape](https://npmjs.com/package/tape), [babel-tape-runner](https://npmjs.com/package/babel-tape-runner) alongside with [babel-preset-env](https://npmjs.com/package/babel-preset-env) or any other babel preset you like. To beautify the output, [faucet](https://github.com/substack/faucet) is used.
No other configuration is needed.
### mocha and chai
[mocha](https://mochajs.org) is a commonly used testing framework for node and in the browser. It is often used in combination with [chai](https://chaijs.com), a BDD/TDD assertion library.
To add mocha into your project, `npm install mocha chai babel-register --save-dev` and call the tests via `mocha --require babel-register`. The require parameter is needed for ES6+ support. If you don't specify a file, mocha executes everything inside the `test` folder.
### Jest
[jest](http://jestjs.io/) by facebook features zero (minimal) configuration, test parallelization and built-in code coverage reports.
### Other testing frameworks and tools (not covered here)
* [Enzyme](https://github.com/airbnb/enzyme) by airbnb is a set of testing utilities for React applications and can be used by any common testing framework.
* [jasmine](https://jasmine.github.io/), a BDD testing framework by Pivotal Labs.
* [ShouldJS](https://shouldjs.github.io) is another assertion library and very similar to chai.