-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Report skipped tests for JUnit & Go formats - Generate a JUnit badge only if at least one file matches - Improve types and naming
- Loading branch information
1 parent
a3b1d30
commit 95c2306
Showing
23 changed files
with
176 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
/** | ||
* Build a tests badge. | ||
* @param {*} data Badge data | ||
* @returns {import('./index.js').Badge} Badge content | ||
* @param {TestReportData} data Test report data | ||
* @returns {BadgeContent} Badge content | ||
*/ | ||
export function buildBadge(data) { | ||
const content = {}; | ||
content.message = `${data.passed} passed`; | ||
content.color = data.passed > 0 ? 'brightgreen' : 'lightgrey'; | ||
if (data.failed > 0) { | ||
content.message += `, ${data.failed} failed`; | ||
content.color = 'red'; | ||
} | ||
if (data.skipped > 0) { | ||
content.message += `, ${data.skipped} skipped`; | ||
} | ||
content.color = data.failed === 0 ? 'brightgreen' : 'red'; | ||
return content; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
import assert from 'assert/strict'; | ||
import { copyFile, mkdir, rm, writeFile } from 'fs/promises'; | ||
import { join } from 'path'; | ||
import { getReports } from './go.js'; | ||
|
||
describe('reports/go', () => { | ||
describe('#getReports()', () => { | ||
it('should return tests and coverage reports', async () => { | ||
const reports = await getReports(join(process.cwd(), 'test/data/go')); | ||
assert.equal(reports.length, 2); | ||
assert.deepEqual(reports, [ | ||
{ type: 'tests', data: { passed: 3, failed: 0, tests: 3 } }, | ||
{ type: 'coverage', data: { coverage: 96.5 } } | ||
]); | ||
before(async () => { | ||
await mkdir('test/data/go/project'); | ||
await writeFile('test/data/go/project/go.mod', ''); | ||
}); | ||
const coverage = { type: 'coverage', data: { coverage: 96.5 } }; | ||
const tests = [ | ||
{ report: 'test.out', expected: [{ type: 'tests', data: { tests: 3, passed: 3, failed: 0, skipped: 0 } }, coverage] }, | ||
{ report: 'failed-test.out', expected: [{ type: 'tests', data: { tests: 6, passed: 3, failed: 2, skipped: 1 } }, coverage] } | ||
]; | ||
for (const { report, expected } of tests) { | ||
it(`should return test and coverage reports for file ${report}`, async () => { | ||
await copyFile(join('test/data/go', report), 'test/data/go/project/test.out'); | ||
const reports = await getReports(join(process.cwd(), 'test/data/go/project')); | ||
assert.equal(reports.length, 2); | ||
assert.deepEqual(reports, expected); | ||
}); | ||
} | ||
after(async () => { | ||
await rm('test/data/go/project', { recursive: true }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.