Skip to content

Instantly share code, notes, and snippets.

@riskers

riskers/ava.md Secret

Last active September 18, 2017 03:24
Show Gist options
  • Save riskers/e40feb1ec5ae3b7856a6bbef50a6bdf5 to your computer and use it in GitHub Desktop.
Save riskers/e40feb1ec5ae3b7856a6bbef50a6bdf5 to your computer and use it in GitHub Desktop.
avajs 的配置与使用
  1. install
npm install ava --save-dev
npm install tap-mocha-reporter --save-dev // 对 ava 来说不是必须的,是为了美化报告
  1. 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",
  1. test case
import test from 'ava';

test('test1', t => {
  t.is(1, 1);
  t.is(2, 3);
});
  1. 覆盖率检测
npm install --save-dev nyc
// package.json

scripts: {
  "test": "nyc --reporter=text ava --tap | tap-spec src/common/*.test.js",  
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment