Skip to content

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

Closed

Conversation

luthfianto
Copy link

Fixes #1525

@luthfianto luthfianto force-pushed the feature/add-watch-mode-commands-info branch from 603f053 to 8de3834 Compare October 17, 2017 16:07
Copy link
Member

@novemberborn novemberborn left a 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`');
Copy link
Member

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.

@novemberborn
Copy link
Member

Hi @rilut, just wondering if there's more commits forthcoming? Would be good to have some assertions on the logger.write() spy, like is done for the other logger methods. Thanks!

@luthfianto
Copy link
Author

Oh sure, will do

@novemberborn
Copy link
Member

@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.

@novemberborn
Copy link
Member

Ah no, the CLI integration tests are failing because there's new output. Could you look into that @rilut? 😄

@luthfianto
Copy link
Author

@novemberborn I'll look into it

@luthfianto luthfianto force-pushed the feature/add-watch-mode-commands-info branch from 771f870 to 00ab140 Compare November 18, 2017 10:18
@luthfianto luthfianto force-pushed the feature/add-watch-mode-commands-info branch from 00ab140 to c90b54a Compare November 18, 2017 10:30
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);
Copy link
Author

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

Copy link
Member

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.

@luthfianto
Copy link
Author

not sure what happened with the node:6 FreshDeps=false tests

@luthfianto
Copy link
Author

luthfianto commented Nov 18, 2017

https://travis-ci.org/avajs/ava/jobs/303922129

test/cli.js ....................................... 138/140 5m
  snapshots work (tests)
  not ok timeout!
    signal: SIGTERM
    handles:
      - type: ChildProcess
        events:
          - close
      - type: Socket
        events:
          - end
          - finish
          - _socketEnd
      - type: Socket
        events:
          - end
          - finish
          - _socketEnd
          - close
          - error
          - data
      - type: Socket
        events:
          - end
          - finish
          - _socketEnd
          - close
          - error
          - data
    expired: TAP
    stack: |
      emit (node_modules/nyc/node_modules/signal-exit/index.js:77:11)
      process.listener (node_modules/nyc/node_modules/signal-exit/index.js:91:7)
      processEmit (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
      process.emit (node_modules/source-map-support/source-map-support.js:439:21)
      processEmit (node_modules/signal-exit/index.js:155:32)
    test: snapshots work (tests)
  
  not ok test count !== plan
    +++ found
    --- wanted
    -1
    +61
    results:
      ok: false
      count: 61
      pass: 60
      fail: 2
      bailout: false
      todo: 0
      skip: 0
      plan:
        start: null
        end: null
        skipAll: false
        skipReason: ''
        comment: ''
      failures:
        - ok: false
          id: 61
          time: 5460.13
          name: snapshots work (tests)
        - tapError: no plan

@novemberborn
Copy link
Member

@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.

Copy link
Member

@novemberborn novemberborn left a 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`);
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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
Copy link
Member

screen shot 2017-12-13 at 13 40 23

It shouldn't reprint the message when I press r+Enter.

@luthfianto
Copy link
Author

luthfianto commented Dec 16, 2017

@sindresorhus So after Ava writing the status in MiniLogger.finish, I need to write the rerunMessage. And delete the rerunMessage using ansiEscapes.eraseLines() every time I pressed r+Enter, right?

Which function do you think the rerunMessage should be in?

@novemberborn
Copy link
Member

@rilut I think what @sindresorhus is seeing is due to my earlier comment:

Unfortunately this doesn't work with the mini reporter: the test output itself is overwritten.

My suggestion for resolving this is https://github.com/avajs/ava/pull/1555/files#r153833345.

@novemberborn
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants