Skip to content

Commit

Permalink
fix: ignore frontend files and document files (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Jun 20, 2017
1 parent 6ab1d93 commit f9d578e
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ coverage/
.tmp
.vscode
*.log
package-lock.json
package-lock.json
.nyc_output
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ install:
test_script:
- node --version
- npm --version
- npm run ci
- npm run test

build: off
10 changes: 8 additions & 2 deletions lib/cmd/cov.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ class CovCommand extends Command {

// you can add ignore dirs here
this[EXCLUDES] = new Set([
'examples/**',
'mocks_*/**',
'example/',
'examples/',
'mocks**/',
'config/',
'app/assets/',
'app/view/',
'app/public/',
'docs/',
].concat(testExclude.defaultExclude));
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"test": "npm run lint -- --fix && npm run test-local",
"test-local": "node bin/egg-bin.js test -t 3600000",
"cov": "nyc -r lcov -r text-summary npm run test-local",
"ci": "npm run lint && npm run pkgfiles && npm run cov",
"ci-test-only": "TESTS=test/lib/cmd/cov.test.js npm run test-local",
"ci": "npm run lint && npm run pkgfiles && npm run ci-test-only && npm run cov",
"autod": "autod"
},
"engines": {
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/test-files/app/assets/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/app/assets/subdir/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/app/public/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/app/public/subdir/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/app/view/subdir/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/config/config.default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/config/config.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/config/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/config/proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/docs/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/example/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/examples/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/mocks/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
3 changes: 3 additions & 0 deletions test/fixtures/test-files/mocks_data/foo/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = '';
28 changes: 19 additions & 9 deletions test/lib/cmd/cov.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ describe('test/lib/cmd/cov.test.js', () => {
it('should success', done => {
mm(process.env, 'TESTS', 'test/**/*.test.js');
mm(process.env, 'NYC_CWD', cwd);
coffee.fork(eggBin, [ 'cov' ], { cwd })
// .debug()
const child = coffee.fork(eggBin, [ 'cov' ], { cwd })
.debug()
.expect('stdout', /should success/)
.expect('stdout', /a\.test\.js/)
.expect('stdout', /b[\/|\\]b\.test\.js/)
.notExpect('stdout', /a.js/)
// .expect('stdout', /Statements {3}: 80% \( 4[\/|\\]5 \)/)
.expect('code', 0)
.notExpect('stdout', /a.js/);

// only test on npm run test
if (!process.env.NYC_ROOT_ID) {
child.expect('stdout', /Statements {3}: 80% \( 4[\/|\\]5 \)/);
}

child.expect('code', 0)
.end(err => {
assert.ifError(err);
assert.ok(fs.existsSync(path.join(cwd, 'coverage/coverage-final.json')));
Expand All @@ -36,14 +41,19 @@ describe('test/lib/cmd/cov.test.js', () => {
it('should success with COV_EXCLUDES', function* () {
mm(process.env, 'TESTS', 'test/**/*.test.js');
mm(process.env, 'COV_EXCLUDES', 'ignore/*');
yield coffee.fork(eggBin, [ 'cov' ], { cwd })
const child = coffee.fork(eggBin, [ 'cov' ], { cwd })
// .debug()
.expect('stdout', /should success/)
.expect('stdout', /a\.test\.js/)
.expect('stdout', /b[\/|\\]b\.test\.js/)
.notExpect('stdout', /a.js/)
// .expect('stdout', /Statements {3}: 75% \( 3[\/|\\]4 \)/)
.expect('code', 0)
.notExpect('stdout', /a.js/);

// only test on npm run test
if (!process.env.NYC_ROOT_ID) {
child.expect('stdout', /Statements {3}: 75% \( 3[\/|\\]4 \)/);
}

yield child.expect('code', 0)
.end();
assert(fs.existsSync(path.join(cwd, 'coverage/coverage-final.json')));
assert(fs.existsSync(path.join(cwd, 'coverage/lcov-report/index.html')));
Expand Down

0 comments on commit f9d578e

Please sign in to comment.