-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Print watch mode shortcut commands #1555
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
Print watch mode shortcut commands #1555
Conversation
603f053
to
8de3834
Compare
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.
Thanks for your PR @rilut!
Could you have a look at the watcher tests? I think you need to add a spy for the write()
method: https://github.com/avajs/ava/blob/3f81fc431016ca115177d2d79cf9db36b05f69ad/test/watcher.js#L76:L82
And some assertions as well.
lib/watcher.js
Outdated
@@ -123,6 +123,7 @@ class Watcher { | |||
.then(runStatus => { | |||
runStatus.previousFailCount = this.sumPreviousFailures(currentVector); | |||
logger.finish(runStatus); | |||
logger.write('[ava] To rerun tests, enter `r`\n[ava] To update snapshots used in the previous test run, enter `u`'); |
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.
I don't think this needs to be prefixed with [ava]
. Currently the key needs to be followed by Enter
in order to be recognized. How about:
To rerun all tests, type 'r', followed by Enter
To update snapshots used in the previous tests, type 'u', followed by Enter
Perhaps using chalk.gray.dim
as the color.
Hi @rilut, just wondering if there's more commits forthcoming? Would be good to have some assertions on the |
Oh sure, will do |
@rilut thanks for following up. I've just restarted CI, so hopefully all the tests will pass. Still need to give this a whirl, have been a bit busy sorry. |
Ah no, the CLI integration tests are failing because there's new output. Could you look into that @rilut? 😄 |
@novemberborn I'll look into it |
771f870
to
00ab140
Compare
00ab140
to
c90b54a
Compare
t.is(buffer.replace(/\s/g, ''), ''); | ||
const rerunMessage = `To rerun all tests, type 'r', followed by Enter\nTo update snapshots used in the previous tests, type 'u', followed by Enter\n`; | ||
const rerunMessageWithoutWhitespace = rerunMessage.replace(/\s/g, ''); | ||
t.is(buffer.replace(/\s/g, ''), rerunMessageWithoutWhitespace); |
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.
@novemberborn I'm not sure if what I did (asserting this) is the right way to do this
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.
Most tests use t.match
for this. You could do an assertion for each line.
not sure what happened with the node:6 FreshDeps=false tests |
https://travis-ci.org/avajs/ava/jobs/303922129
|
@rilut the CI failures seem to be intermittent. I'm running out of time for today but I'll try and have a look at this tomorrow. |
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.
OK, CI is passing 🎉
Unfortunately this doesn't work with the mini reporter: the test output itself is overwritten. It's fine with the verbose reporter though. I also think we should tweak some of the colors, see inline comments.
Thank you for your work on this @rilut, sorry for taking a bit longer to get back to you on this PR.
@@ -18,6 +19,7 @@ function rethrowAsync(err) { | |||
|
|||
const MIN_DEBOUNCE_DELAY = 10; | |||
const INITIAL_DEBOUNCE_DELAY = 100; | |||
const rerunMessage = chalk.gray.dim(`To rerun all tests, type 'r', followed by Enter\nTo update snapshots used in the previous tests, type 'u', followed by Enter\n`); |
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.
Looking at this in my terminal I think this should just be chalk.gray
. But we then should also update the timestamp output in the mini & verbose loggers to not be dimmed.
t.is(buffer.replace(/\s/g, ''), ''); | ||
const rerunMessage = `To rerun all tests, type 'r', followed by Enter\nTo update snapshots used in the previous tests, type 'u', followed by Enter\n`; | ||
const rerunMessageWithoutWhitespace = rerunMessage.replace(/\s/g, ''); | ||
t.is(buffer.replace(/\s/g, ''), rerunMessageWithoutWhitespace); |
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.
Most tests use t.match
for this. You could do an assertion for each line.
@@ -126,6 +128,7 @@ class Watcher { | |||
.then(runStatus => { | |||
runStatus.previousFailCount = this.sumPreviousFailures(currentVector); | |||
logger.finish(runStatus); | |||
logger.write(rerunMessage); |
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.
Unfortunately this doesn't work with the mini reporter. I think finish()
should take an optional second parameter, call it footer
perhaps, and both the mini and verbose loggers can then include this in their regular output.
@sindresorhus So after Ava writing the Which function do you think the |
@rilut I think what @sindresorhus is seeing is due to my earlier comment:
My suggestion for resolving this is https://github.com/avajs/ava/pull/1555/files#r153833345. |
Closing this since it has stalled. If anybody is looking to revive this PR please check in first, I'm considering refactoring the reporter pipeline which impacts this PR. |
Fixes #1525