-
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 and improve types
- Loading branch information
1 parent
a3b1d30
commit 0f0adfa
Showing
13 changed files
with
76 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
/** | ||
* Build a tests badge. | ||
* @param {*} data Badge data | ||
* @param {import('../reports/index.js').TestReportData} data Test report data | ||
* @returns {import('./index.js').Badge} 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
import assert from 'assert/strict'; | ||
import { mkdir, writeFile, copyFile, rm } 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 tests 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
=== RUN Test | ||
=== RUN Test/example/1 | ||
=== RUN Test/example/2 | ||
=== RUN Test/example/3 | ||
=== RUN Test/example/4 | ||
=== RUN Test/example/5 | ||
--- FAIL: Test (0.01s) | ||
--- PASS: Test/example/1 (0.00s) | ||
--- PASS: Test/example/2 (0.01s) | ||
--- SKIP: Test/example/3 (0.00s) | ||
--- FAIL: Test/example/4 (0.01s) | ||
--- PASS: Test/example/5 (0.01s) | ||
FAIL | ||
coverage: 96.5% of statements in ./... | ||
ok github.com/example/test 0.111s coverage: 96.5% of statements in ./... |
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