New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output logs for tests that remain pending when AVA exits #3125
Output logs for tests that remain pending when AVA exits #3125
Conversation
unecessary dif temp add logs for pending tests fix linting issues undo unecessary change
0ff9efc
to
ce2b12e
Compare
This is the output with the same code snippet on #3122 . Before I attempt writing test cases for this, do you think this looks good implementation-wise and output-wise?
|
lib/run-status.js
Outdated
@@ -9,6 +9,7 @@ export default class RunStatus extends Emittery { | |||
super(); | |||
|
|||
this.pendingTests = new Map(); | |||
this.pendingTestsLogReference = new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate map from this.pendingTests
because they are modified and initialized in different events with different objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why Reference
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, I think pendingTestsLogs
sounds better
@kevo1ution this is on my list to look at more closely, but at first glance it seems reasonable. |
thanks I'll start adding several tests to confirm that the output works, and mark this ready for review when it's ready to be looked at |
@novemberborn This is ready for review. It took some time to figure out how testing the testing framework works (lol), so hopefully, I did it up to your standards. Let me know if there is anything I missed |
@novemberborn bumping on this, let me know if there's anything else I need to do, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Left some comments and suggestions around optional chaining.
lib/reporters/default.js
Outdated
@@ -370,8 +370,11 @@ export default class Reporter { | |||
} | |||
|
|||
this.lineWriter.writeLine(`${testsInFile.size} tests were pending in ${this.relativeFile(file)}\n`); | |||
const testTitleToLogs = evt.pendingTestsLogReference.get(file) ?? new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const testTitleToLogs = evt.pendingTestsLogReference.get(file) ?? new Map(); | |
const testTitleToLogs = evt.pendingTestsLogReference.get(file); |
lib/reporters/default.js
Outdated
for (const title of testsInFile) { | ||
const logs = testTitleToLogs.get(title) ?? []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writeLogs()
can handle falsey logs
values. So with optional chaining and the above we can do:
const logs = testTitleToLogs.get(title) ?? []; | |
const logs = testTitleToLogs?.get(title); |
lib/run-status.js
Outdated
@@ -9,6 +9,7 @@ export default class RunStatus extends Emittery { | |||
super(); | |||
|
|||
this.pendingTests = new Map(); | |||
this.pendingTestsLogReference = new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why Reference
?
lib/run-status.js
Outdated
if (this.pendingTestsLogReference.has(event.testFile)) { | ||
this.pendingTestsLogReference.get(event.testFile).set(event.title, event.logs); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this.pendingTestsLogReference.has(event.testFile)) { | |
this.pendingTestsLogReference.get(event.testFile).set(event.title, event.logs); | |
} | |
this.pendingTestsLogReference.get(event.testFile)?.set(event.title, event.logs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely!
Thank you for the helpful reviews and insight on fixing the issue! Looking forward to using this fix in my repos |
Fixes #3122 , #2780
What
This PR plumbs test logs to be printed when tests timeout due to the global timeout set by
ava --timeout <timeout>
command.Why
t.log
is a very useful utility for debugging what happens when a test fails. When a test times out, these logs are useful for figuring out why the tests timed out.