Fixes #422: Add nyc lcov-based code coverage for tests (#565)

* Add nyc lcov-based code coverage for tests

* Add codecov to travis

* Add codecov badge to README
This commit is contained in:
David Humphrey 2018-11-28 19:24:03 -05:00 committed by GitHub
parent 89626107cc
commit 725bfbf30c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1355 additions and 11 deletions

4
.gitignore vendored
View File

@ -8,3 +8,7 @@ dist/filer-issue225.js
# Parcel build dirs
.cache
tests/dist
# nyc code coverage
.nyc_output
coverage

View File

@ -11,6 +11,11 @@ addons:
before_install:
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
after_success:
- npm install -g codecov
- npm run coverage
- codecov
notifications:
email: false
irc: "irc.mozilla.org#filer"

View File

@ -2,6 +2,8 @@
[![Build Status](https://secure.travis-ci.org/filerjs/filer.png?branch=develop)](http://travis-ci.org/filerjs/filer)
[![codecov](https://codecov.io/gh/filerjs/filer/branch/master/graph/badge.svg)](https://codecov.io/gh/filerjs/filer)
### Filer
Filer is a POSIX-like file system interface for node.js and browser-based JavaScript.

1314
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,8 @@
"prebuild": "parcel build --global Filer src/index.js --no-minify --out-file filer.js",
"build": "parcel build --global Filer src/index.js --out-file filer.min.js --detailed-report",
"prekarma-mocha": "parcel build tests/index.js --no-source-maps --out-dir tests/dist",
"karma-mocha": "karma start karma.conf.js"
"karma-mocha": "karma start karma.conf.js",
"coverage": "nyc mocha tests/index.js"
},
"repository": {
"type": "git",
@ -47,8 +48,20 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"parcel-bundler": "^1.9.6"
},
"main": "./src/index.js",
"browser": "./dist/filer.min.js"
"browser": "./dist/filer.min.js",
"nyc": {
"exclude": [
"tests/**/*.js",
"lib/**/*.js",
"src/providers/**/*.js"
],
"reporter": [
"lcov",
"text"
]
}
}

View File

@ -95,14 +95,14 @@ function setup(callback) {
function fs() {
if(!_fs) {
throw 'TestUtil: call setup() before fs()';
throw new Error('TestUtil: call setup() before fs()');
}
return _fs;
}
function provider() {
if(!_provider) {
throw 'TestUtil: call setup() before provider()';
throw new Error('TestUtil: call setup() before provider()');
}
return _provider;
}

View File

@ -6,28 +6,24 @@ describe('fs.Shell', function() {
beforeEach(util.setup);
afterEach(util.cleanup);
it('is a function', function(done) {
it('is a function', function() {
var fs = util.fs();
expect(typeof fs.Shell).to.equal('function');
done();
});
it('should return a FileSystemShell instance', function(done) {
it('should return a FileSystemShell instance', function() {
var fs = util.fs();
var sh = new fs.Shell();
expect(sh.prototype).to.deep.equal((new Filer.Shell(fs)).prototype);
done();
});
it('should reflect changes to the prototype', function(done){
it('should reflect changes to the prototype', function(){
var fs = util.fs();
var sh = new fs.Shell();
Filer.Shell.prototype.test = 'foo';
expect(sh.test).to.equal('foo');
done();
});
});

View File

@ -2,6 +2,16 @@ var util = require('../lib/test-utils.js');
var expect = require('chai').expect;
describe('fs.watch', function() {
// Our watch infrastucture is dependent on document.localStorage
// see lib/intercom.js. Bail if we don't have access to it.
before(function() {
if(!(global.document && global.document.localStorage)) {
/* eslint no-console: 0 */
console.log('Skipping fs.watch() tests--not supported in current environment.');
this.skip();
}
});
beforeEach(util.setup);
afterEach(util.cleanup);