Skip to content
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 todo and skip descriptions when in verbose mode #8038

Merged
merged 12 commits into from Mar 19, 2019

Conversation

@natealcedo
Copy link
Contributor

natealcedo commented Mar 4, 2019

Summary

Prints the text in test.todo and test.skip calls when in verbose mode

Fixes #7999

Test plan

Added some integration integration tests under testTodo

summedTests.todo.forEach(todoTest => {
this._logTodoTest(
'todo',
this._getIcon('todo'),

This comment has been minimized.

Copy link
@SimenB

SimenB Mar 4, 2019

Collaborator

seems silly to pass in the icons and title, but I see it's consistent

This comment has been minimized.

Copy link
@natealcedo

natealcedo Mar 4, 2019

Author Contributor

Yup. Didn't want to stray too far from what was being done. The same could be said for printing skipped tests

This comment has been minimized.

Copy link
@mattphillips

mattphillips Mar 4, 2019

Collaborator

I think given that we are explicitly pulling this behaviour out into _logTodoTest we should just move the concrete data into the function definition.

 private _logTodoTest(
    todoTest: TestResult.AssertionResult,
    indentLevel: number,
  ) {
    const text = chalk.dim(`todo ${todoTest.title}`);
    this._logLine(`${this._getIcon('todo')} ${text}`, indentLevel);
  }

Then if you want to be fancy you could curry this to:

 private _logTodoTest = (indentLevel: number) => (todoTest: TestResult.AssertionResult) => {
    const text = chalk.dim(`todo ${todoTest.title}`);
    this._logLine(`${this._getIcon('todo')} ${text}`, indentLevel);
  }

and then you can just do the following in the forEach:

summedTests.todo.forEach(this._logTodoTest(indentLevel));

This comment has been minimized.

Copy link
@natealcedo

natealcedo Mar 5, 2019

Author Contributor

I like this approach. Should we do a similar approach to skipped tests then since their functions are very similar?

@SimenB
SimenB approved these changes Mar 4, 2019
Copy link
Collaborator

SimenB left a comment

Thanks! Just missing changelog

@SimenB SimenB requested a review from thymikee Mar 4, 2019
natealcedo and others added 2 commits Mar 4, 2019
@SimenB SimenB requested a review from mattphillips Mar 4, 2019
@natealcedo

This comment has been minimized.

Copy link
Contributor Author

natealcedo commented Mar 5, 2019

I've just pushed in some changes where skipped tests get the same treatment as per the original PR. One thing to note is that I wrap the description in quotes now since some descriptions might be long.
Let me know what you guys think.

Edit: I'll revert adding the quotes since I just noticed that they're not there for passing tests as well

@natealcedo natealcedo changed the title Print todo descriptions when in verbose mode Print todo and skip descriptions when in verbose mode Mar 7, 2019
@natealcedo

This comment has been minimized.

Copy link
Contributor Author

natealcedo commented Mar 19, 2019

Hey just following up. What else does this PR need to get merged?

@SimenB

This comment has been minimized.

Copy link
Collaborator

SimenB commented Mar 19, 2019

What else does this PR need to get merged?

Nothing!

@SimenB SimenB merged commit 809ab98 into facebook:master Mar 19, 2019
12 checks passed
12 checks passed
ci/circleci: lint-and-typecheck Your tests passed on CircleCI!
Details
ci/circleci: test-browser Your tests passed on CircleCI!
Details
ci/circleci: test-jest-circus Your tests passed on CircleCI!
Details
ci/circleci: test-node-10 Your tests passed on CircleCI!
Details
ci/circleci: test-node-11 Your tests passed on CircleCI!
Details
ci/circleci: test-node-6 Your tests passed on CircleCI!
Details
ci/circleci: test-node-8 Your tests passed on CircleCI!
Details
ci/circleci: test-or-deploy-website Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details
facebook.jest #20190318.18 succeeded
Details
@Akswii

This comment has been minimized.

Copy link

Akswii commented Apr 10, 2019

I know this is merged/closed, but is there anyway to list just the todos? When you have a lot of tests then showing it in verbose will be kind of hard to pickup.

@SimenB

This comment has been minimized.

Copy link
Collaborator

SimenB commented Apr 10, 2019

We could probably pass an option to the reporter enabling this. Wanna open a PR? If not, please open up an issue

@natealcedo

This comment has been minimized.

Copy link
Contributor Author

natealcedo commented Apr 11, 2019

I can pick this up. How would this work from a user’s point of view though? I imagine this would need another configuration option?

@SimenB

This comment has been minimized.

Copy link
Collaborator

SimenB commented Apr 11, 2019

Yeah, something like reporters: [['default', {showTodoTitleWhenVerbose: true}]] or something similar, without the horrible name

@natealcedo

This comment has been minimized.

Copy link
Contributor Author

natealcedo commented Apr 11, 2019

So I can foresee 2 things here.

  1. We only show the 'showTodoTitleWhenVerbose' when it's passed as an option in
  2. This behavior is not enabled by default when running jest with --verbose or when verbose: true is set.

That right?

@SimenB

This comment has been minimized.

Copy link
Collaborator

SimenB commented Apr 11, 2019

Default to showing it, I think? /cc @scotthovestadt @thymikee @jeysal @mattphillips

@natealcedo

This comment has been minimized.

Copy link
Contributor Author

natealcedo commented Apr 11, 2019

Ok I think I may have misread @Akswii 's request. Right now, in verbose mode. We print all test names. I think what he's asking is for the ability to show only the test names of the todo tests and everything else will be as per before. i.e. "3 skipped", Correct me if I'm wrong @Akswii

@natealcedo natealcedo deleted the natealcedo:feature/add-todo-test-description branch Apr 11, 2019
@Akswii

This comment has been minimized.

Copy link

Akswii commented Apr 11, 2019

@natealcedo Exactly! I wish to use test.todo to outline my future work load, and it would be a nice feature to be able to list only the todos. I'm working on a project with a ton of tests, and it's impossible to see what the todos are when the tests are running in verbose mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.