Skip to content

Commit 40be597

Browse files
committed
Update mini reporter to include files-without-tests in final output
1 parent 99072ed commit 40be597

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

lib/reporters/mini.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class MiniReporter {
103103
this.failFastEnabled = false;
104104
this.failures = [];
105105
this.filesWithMissingAvaImports = new Set();
106+
this.filesWithoutDeclaredTests = new Set();
106107
this.internalErrors = [];
107108
this.knownFailures = [];
108109
this.matching = false;
@@ -183,10 +184,15 @@ class MiniReporter {
183184
this.unhandledRejections.push(evt);
184185
break;
185186
case 'worker-failed':
186-
// Ignore
187+
if (this.stats.byFile.get(evt.testFile).declaredTests === 0) {
188+
this.filesWithoutDeclaredTests.add(evt.testFile);
189+
}
187190
break;
188191
case 'worker-finished':
189-
// Ignore
192+
if (this.stats.byFile.get(evt.testFile).declaredTests === 0) {
193+
this.filesWithoutDeclaredTests.add(evt.testFile);
194+
this.writeWithCounts(colors.error(`${figures.cross} No tests found in ${path.relative('.', evt.testFile)}`));
195+
}
190196
break;
191197
case 'worker-stderr':
192198
case 'worker-stdout':
@@ -353,6 +359,26 @@ class MiniReporter {
353359
' ' + chalk.gray.dim('[' + new Date().toLocaleTimeString('en-US', {hour12: false}) + ']') :
354360
'';
355361

362+
if (this.filesWithMissingAvaImports.size > 0) {
363+
for (const testFile of this.filesWithMissingAvaImports) {
364+
this.lineWriter.writeLine(colors.error(`${figures.cross} No tests found in ${path.relative('.', testFile)}, make sure to import "ava" at the top of your test file`) + firstLinePostfix);
365+
firstLinePostfix = '';
366+
}
367+
}
368+
369+
if (this.filesWithoutDeclaredTests.size > 0) {
370+
for (const testFile of this.filesWithoutDeclaredTests) {
371+
if (!this.filesWithMissingAvaImports.has(testFile)) {
372+
this.lineWriter.writeLine(colors.error(`${figures.cross} No tests found in ${path.relative('.', testFile)}`) + firstLinePostfix);
373+
firstLinePostfix = '';
374+
}
375+
}
376+
}
377+
378+
if (this.filesWithMissingAvaImports.size > 0 || this.filesWithoutDeclaredTests.size > 0) {
379+
this.lineWriter.writeLine();
380+
}
381+
356382
if (this.stats.failedHooks > 0) {
357383
this.lineWriter.writeLine(colors.error(`${this.stats.failedHooks} ${plur('hook', this.stats.failedHooks)} failed`) + firstLinePostfix);
358384
firstLinePostfix = '';

test/reporters/mini.edgecases.log

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
---tty-stream-chunk-separator
44
* ---tty-stream-chunk-separator
55
---tty-stream-chunk-separator
6+
* ✖ No tests found in test/fixture/report/edge-cases/ava-import-no-test-declaration.js---tty-stream-chunk-separator
7+
---tty-stream-chunk-separator
68
* ✖ No tests found in test/fixture/report/edge-cases/no-ava-import.js, make sure to import "ava" at the top of your test file---tty-stream-chunk-separator
79
---tty-stream-chunk-separator
810
[?25h
11+
✖ No tests found in test/fixture/report/edge-cases/no-ava-import.js, make sure to import "ava" at the top of your test file
12+
✖ No tests found in test/fixture/report/edge-cases/ava-import-no-test-declaration.js
13+
✖ No tests found in test/fixture/report/edge-cases/throws.js
14+
✖ No tests found in test/fixture/report/edge-cases/import-and-use-test-member.js
15+
916
2 uncaught exceptions
1017

1118
Uncaught exception in test/fixture/report/edge-cases/throws.js

test/reporters/mini.regular.log

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ stderr
111111
1 todo---tty-stream-chunk-separator
112112
---tty-stream-chunk-separator
113113
[?25h
114+
✖ No tests found in test/fixture/report/regular/bad-test-chain.js
115+
114116
8 tests failed
115117
1 known failure
116118
1 test skipped

test/reporters/mini.typescript.log

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* ---tty-stream-chunk-separator
55
---tty-stream-chunk-separator
66
[?25h
7+
✖ No tests found in test/fixture/report/typescript/build-error.ts
8+
79
1 uncaught exception
810

911
Uncaught exception in test/fixture/report/typescript/build-error.ts

0 commit comments

Comments
 (0)