Eater
Eater is Ea sy t est runn er . Eater has one simple rule.
If test file outputs `stderr` message, the test failed.
Features
- Multi-process: All eater test files run as separate processes and eater does not launch too many processes more than CPU-core number.
- Easy mock: An eater test does not affect the other tests, but mock object sometimes kills your test.
- Happy async: eater aims is here to handle async test well. Each eater files will run in
Node.js
child_process, so the tests always should be async first. If your tests mix sync and async tests, you will have a headache to maintain the tests.
Demo
How to use
1. Install
$ npm install eater -g
2. Write some tests
// test/sometest.jsconst assert = ;; // always failure
Run
$ eater
--dir
and --ext
and --glob
eater eater searches JavaScript files under process.cwd()/test
dir by default. If you want to change the dir, use --dir
option.
$ eater --dir spec/
And if you changed test file extension, like .jsx/.es6/.test.js
, you use --ext
option.
$ eater --ext jsx
eater can find test files using glob pattern match. you use --glob
option.
$ eater --glob **/__test/**/*.js
file
$ eater test/sometest.js test/foo.js test/bar.jd
power-assert user
If you arepower-assert
and espower-loader
1. install $ npm install eater -D
$ npm install power-assert espower-loader -D
power-assert
2. enable // script/enable-power-assert.js cwd: process pattern: 'test/**/*.js';
--require
3. run tests with $ eater --require ./script/enable-power-assert.js
If you are babel(JSX) user
babel-register
or active-cache-babel-register
1. install $ npm install eater -D
$ npm install babel-register -D
or
$ npm install eater -D
$ npm install active-cache-babel-register -D
Note: active-cache-babel-register improves babel transpilation performance.
babel
2. enable // script/enable-babel.js // or to use require('active-cache-babel-register') { if file return true; return false; };
--require
3. run tests with $ eater --require ./script/enable-babel.js
if you are power-assert and babel user:
1. install babel-preset-power-assert
$ npm install babel-preset-power-assert -D
2. write your .babelrc
{
"presets": ["es2015", "babel-preset-power-assert"]
}
--require
3. run tests with $ eater --require ./script/enable-babel.js
Coverage
1. install nyc instead of istanbul
$ npm install nyc -D
2. run test with nyc
$ nyc eater
eater runner settings
eater reads the arguments from settings.
- package.json
- .eaterrc
package.json
"name": "eaterDemo" "version": "1.0.0" "scripts": "test": "eater" "eater": "dir": "test/core" "require": "./enable-power-assert.js" "./enable-jsx.js"
.eaterrc
.eaterrc is JSON5 format so you can write comment and trailing commas.
dir: "test/core" require: "./enable-power-assert.js" "./enable-jsx.js"
runner
If you would like to use test runner, eater has test
function.
const calc = ;const test = test;const assert = ; ; ;
Note that each subtests also run as separated processes, you don't have to care about sync/async stuff.
Use custom reporter
$ npm install eater-pacman-reporter
$ eater --reporter eater-pacman-reporter
Custom Reporters
Exclusive feature
The exclusivity feature allows you to run only
the specified test code by adding // eater:only
comment on top of your test code. Here's an example.
// eater:onlyconst test = test;const mustCall = ;const assert = ; ;
And if you need to exclude your test case, only
function is helpful.
// eater:onlyconst only = only;const test = test;const mustCall = ;const assert = ; ; ;