- install
npm install ava --save-dev
npm install tap-mocha-reporter --save-dev // 对 ava 来说不是必须的,是为了美化报告
- config
// package.json
"ava": {
"babel": "inherit",
"require": [
"babel-register"
],
"failFast": true,
"failWithoutAssertions": false,
"concurrency": 5,
"powerAssert": false
},
"test": "ava --tap | tap-mocha-reporter spec src/common/*.test.js",
- test case
import test from 'ava';
test('test1', t => {
t.is(1, 1);
t.is(2, 3);
});
- 覆盖率检测
npm install --save-dev nyc
// package.json
scripts: {
"test": "nyc --reporter=text ava --tap | tap-spec src/common/*.test.js",
}