Skip to content

Commit

Permalink
fix: #26 unit test coverage reporting and reporting error code on tes…
Browse files Browse the repository at this point in the history
…t failure
  • Loading branch information
nkrusch committed Feb 24, 2021
1 parent d42edb8 commit d3bba9d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions cli/xt-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ const proc = exec([
' --require @babel/register ',

// output colors
'--colors',

// lastly: pipe to coveralls -->
// this has to happen last after all tests have run
coverage ? '&& nyc report --reporter=text-lcov | coveralls' : ''
'--colors'

].join(' '));

Expand All @@ -77,7 +73,18 @@ proc.stdout.on('data', data => {

proc.stderr.on('data', data => {
process.stdout.write(data.toString());
if (coverage) {
process.exit(1);
});

proc.on('exit', code => {
// unit test proc must finish without error
if (code === 0) {
if (coverage) {
// lastly: pipe to coveralls -->
// after all tests have run AND
// only if tests completed without error
exec('nyc report --reporter=text-lcov | coveralls');
}
}
// exit main process with the unit test result code
process.exit(code);
});

0 comments on commit d3bba9d

Please sign in to comment.