Skip to content

Commit 8e04cc9

Browse files
committed
test
1 parent f3f3a7b commit 8e04cc9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

test/test-reporter.mjs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
function colorize (type, text) {
22
if (type === 'pass') {
33
const whiteText = `\x1b[30m${text}`
4-
// Green background with black text
5-
return `\x1b[42m${whiteText}\x1b[0m`
4+
const boldWhiteText = `\x1b[1m${whiteText}`
5+
// Green background with white text
6+
return `\x1b[42m${boldWhiteText}\x1b[0m`
67
}
78

89
if (type === 'fail') {
910
const blackText = `\x1b[37m${text}`
10-
// Red background with white text
11-
return `\x1b[41m${blackText}\x1b[0m`
11+
const boldBlackText = `\x1b[1m${blackText}`
12+
// Red background with black text
13+
return `\x1b[41m${boldBlackText}\x1b[0m`
1214
}
1315

1416
return text
@@ -23,18 +25,17 @@ function formatDiagnosticStr (str) {
2325
async function * reporter (source) {
2426
const failed = new Set()
2527
const diagnostics = new Set()
26-
diagnostics.add('\n\n')
2728

2829
for await (const event of source) {
2930
switch (event.type) {
3031
case 'test:pass': {
31-
yield `${colorize('pass', 'PASSED')}: ${event.data.file}\n`
32+
yield `${colorize('pass', 'PASSED')}: ${event.data.file || event.data.name}\n`
3233
break
3334
}
3435

3536
case 'test:fail': {
36-
failed.add(event.data.file)
37-
yield `${colorize('fail', 'FAILED')}: ${event.data.file}\n`
37+
failed.add(event.data.name || event.data.file)
38+
yield `${colorize('fail', 'FAILED')}: ${event.data.file || event.data.name}\n`
3839
break
3940
}
4041

@@ -54,13 +55,13 @@ async function * reporter (source) {
5455
for (const file of failed) {
5556
yield `${file}\n`
5657
}
58+
yield '\n'
5759
}
5860

59-
diagnostics.add('\n')
60-
6161
for (const diagnostic of diagnostics) {
6262
yield `${diagnostic}`
6363
}
64+
yield '\n'
6465
}
6566

6667
export default reporter

0 commit comments

Comments
 (0)