Skip to content

Commit

Permalink
Test Refactor (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkHerhold committed Mar 10, 2019
1 parent ed81445 commit 3bec89f
Show file tree
Hide file tree
Showing 11 changed files with 382 additions and 414 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
env: {
commonjs: true,
es6: true,
node: true,
mocha: true
},
extends: 'airbnb-base',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
'consistent-return': 0
},
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
node_modules
npm-debug.log
yarn.lock
package-lock.json
package-lock.json
coverage/
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
language: node_js
node_js:
- "6"
- "8"
- "10"
- "11"
matrix:
include:
- node_js: '10'
env: COVERAGE=true # c8 only works on Node.js 10+
script: |
if [ -z "$COVERAGE" ]
then
npm test
else
npm run coverage
fi
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 5.0.0 (Unreleased)

### Breaking Changes
- drops support for Node.js 6

### Non-Breaking Changes
- TODO

## 4.1.0
- adds `parsedMethods` option to specify which request methods will be parsed
- deprecates `strict` option, which will be removed in koa-body 5.0.0
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ Some applications require crytopgraphic verification of request bodies, for exam
## Changelog
Please see the [Changelog](./CHANGELOG.md) for a summary of changes.

## Tests
```
$ npm test
```
## Tests/Coverage
See the [testing readme](./test/README.md).

## License
The MIT License, 2014 [Charlike Mike Reagent](https://github.com/tunnckoCore) ([@tunnckoCore](https://twitter.com/tunnckoCore)) and [Daryl Lau](https://github.com/dlau) ([@daryllau](https://twitter.com/daryllau))
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"main": "index.js",
"types": "./index.d.ts",
"scripts": {
"test": "mocha",
"test": "mocha && eslint ./test",
"coverage": "c8 --check-coverage --lines 85 --functions 100 --branches 70 mocha",
"coverage:html": "npm run coverage && c8 report --reporter=html && echo 'Coverage report generated, open coverage/index.html in your browser'",
"examples-multer": "node examples/multer.js",
"examples-koa-router": "node examples/koa-router.js"
},
Expand Down Expand Up @@ -42,12 +44,16 @@
},
"devDependencies": {
"@types/koa": "^2.0.39",
"c8": "3.4.0",
"chai": "4.2.0",
"eslint": "5.15.1",
"eslint-config-airbnb-base": "13.1.0",
"eslint-plugin-import": "2.16.0",
"koa": "^2.0.0",
"koa-router": "^7.0.1",
"mocha": "5.2.0",
"should": "13.2.1",
"mocha": "6.0.2",
"sinon": "^7.2.2",
"supertest": "3.1.0"
"supertest": "3.4.2"
},
"contributors": [
{
Expand Down
17 changes: 17 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# koa-body Test Info

Running tests:
```sh
npm install
npm test
```

## Coverage
To run coverage, you must be using [c8's supported version](https://github.com/bcoe/c8#supported-nodejs-versions) of Node.js, v10.12.0+.

To get an HTML coverage report, run the following commands:
```sh
npm run coverage:html
```

CI will fail if a line, function, and branch coverage percentage is not met. This is set in `package.json` in the `coverage` script.
Loading

0 comments on commit 3bec89f

Please sign in to comment.