Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore frontend files and document files #65

Merged
merged 4 commits into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 7 additions & 2 deletions lib/cmd/cov.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ class CovCommand extends Command {

// you can add ignore dirs here
this[EXCLUDES] = new Set([
'examples/**',
'mocks_*/**',
'example/',
'examples/',
'mocks**/',
'app/assets/',
'app/view/',
'app/public/',
'docs/',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@popomore app/config 目录怎样解?

].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/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