Skip to content

Commit

Permalink
feat: output cobertura report by default (#226)
Browse files Browse the repository at this point in the history
skip unstable dts test case tempororily
  • Loading branch information
gxkl authored Apr 18, 2023
1 parent b989791 commit 44b9ed8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/cmd/cov.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class CovCommand extends Command {
c8: {
description: 'c8 instruments passthrough',
type: 'string',
default: '--temp-directory ./node_modules/.c8_output -r text-summary -r json-summary -r json -r lcov',
default: '--temp-directory ./node_modules/.c8_output -r text-summary -r json-summary -r json -r lcov -r cobertura',
},
'c8-report': {
description: 'use c8 to report coverage, default to false',
description: 'use c8 to report coverage, default to true',
type: 'boolean',
default: true,
},
Expand Down
2 changes: 1 addition & 1 deletion lib/cmd/node-test-cov.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class NodeTestCovCommand extends NodeTestCommand {
c8: {
description: 'c8 instruments passthrough',
type: 'string',
default: '--temp-directory ./node_modules/.c8_output -r text-summary -r json-summary -r json -r lcov',
default: '--temp-directory ./node_modules/.c8_output -r text-summary -r json-summary -r json -r lcov -r cobertura',
},
};

Expand Down
1 change: 1 addition & 0 deletions test/lib/cmd/cov-c8-report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('test/lib/cmd/cov-c8-report.test.js', () => {
assert.ok(fs.existsSync(path.join(cwd, 'coverage/coverage-summary.json')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/lcov-report/index.html')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/lcov.info')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/cobertura-coverage.xml')));
}

it('should success when c8-report', async () => {
Expand Down
1 change: 1 addition & 0 deletions test/lib/cmd/cov.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('test/lib/cmd/cov.test.js', () => {
assert.ok(fs.existsSync(path.join(cwd, 'coverage/coverage-summary.json')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/lcov-report/index.html')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/lcov.info')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/cobertura-coverage.xml')));
}

it('should success', async () => {
Expand Down
17 changes: 15 additions & 2 deletions test/node-test-cov.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const coffee = require('coffee');

describe('test/node-test-cov.test.js', () => {
const eggBin = require.resolve('../bin/egg-bin.js');
const cwd = path.join(__dirname, 'fixtures/node-test');

it('should run with node-test mode work', () => {
return coffee.fork(eggBin, [ 'node-test-cov' ], { cwd })
beforeEach(() => fs.rmSync(path.join(cwd, 'coverage'), { force: true, recursive: true }));

function assertCoverage(cwd) {
assert.ok(fs.existsSync(path.join(cwd, 'coverage/coverage-final.json')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/coverage-summary.json')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/lcov-report/index.html')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/lcov.info')));
assert.ok(fs.existsSync(path.join(cwd, 'coverage/cobertura-coverage.xml')));
}

it('should run with node-test mode work', async () => {
await coffee.fork(eggBin, [ 'node-test-cov' ], { cwd })
.debug()
.expect('stdout', /# tests 2/)
.expect('stdout', /# pass 1/)
.expect('stdout', /# fail 1/)
.expect('stdout', /Statements {3}: 100% \( 3\/3 \)/)
.expect('code', 1)
.end();
assertCoverage(cwd);
});
});
4 changes: 2 additions & 2 deletions test/ts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ describe('test/ts.test.js', () => {
fs.writeFileSync(path.resolve(cwd, './package.json'), JSON.stringify(pkgJson, null, 2));
});

it('should load egg-ts-helper with dts flag', () => {
it.skip('should load egg-ts-helper with dts flag', () => {
fs.mkdirSync(path.join(cwd, 'typings'));
return coffee.fork(eggBin, [ 'dev', '--dts' ], { cwd })
// .debug()
Expand All @@ -389,7 +389,7 @@ describe('test/ts.test.js', () => {
.end();
});

it('should load egg-ts-helper with egg.declarations = true', () => {
it.skip('should load egg-ts-helper with egg.declarations = true', () => {
fs.mkdirSync(path.join(cwd, 'typings'));
pkgJson.egg.declarations = true;
fs.writeFileSync(path.resolve(cwd, './package.json'), JSON.stringify(pkgJson, null, 2));
Expand Down

0 comments on commit 44b9ed8

Please sign in to comment.