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

prevent newline on test runs - fixes #1781 #7167

Closed
wants to merge 5 commits into from

Conversation

Brantron
Copy link

@Brantron Brantron commented Oct 15, 2018

Summary

This solves #1781 - removes newlines for all specs unless in verbose mode

Test plan

Looks good normal and --verbose 🤷‍♂️

screen shot 2018-10-15 at 10 11 31 am

@@ -137,7 +137,7 @@ export default class Status {

// $FlowFixMe
const width: number = process.stdout.columns;
let content = '\n';
let content = process.argv.includes('--verbose') ? '\n' : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should have access to globalConfig in here, which you can check for the verbose flag

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add it as an argument on the get method to gain access but I wasn't sure that was the right solution. I can update it if that's preferred

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, pass it into the constructor and assign it to this

@SimenB SimenB requested a review from thymikee October 15, 2018 17:22
CHANGELOG.md Outdated
@@ -15,6 +15,7 @@

### Fixes

- `[jest-cli]` Remove newline from initial test runs ([#7153](https://github.com/facebook/jest/pull/7153))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not 7153, this is 7167

@rickhanlonii
Copy link
Member

Woah! Looks too easy to be true cc @cpojer @aaronabramov

@Brantron
Copy link
Author

@SimenB thanks for the fast 👁 issues fixed

@Brantron Brantron force-pushed the brantron/newline branch 3 times, most recently from c8e0add to 29d37bf Compare October 15, 2018 17:36
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be tested, but the code LGTM

@thymikee
Copy link
Collaborator

So, it removes the newline, but what the issue is not telling, it's about the watch mode reporter mostly (top newline before first tests to pass/fail is annoying). Also what we get now:

screenshot 2018-10-16 at 08 18 59

Which isn't an such an improvement imho. I'd like to keep the newline between PASS/FAIL and RUNS as it used to be, but in watch mode I'd like the newline only be present when there are tests that are already executed.

Attaching a preview of what would be an ideal solution to this problem (to me at least):

not good good
master screenshot 2018-10-16 at 08 23 02 this PR screenshot 2018-10-16 at 08 27 45 this PR screenshot 2018-10-16 at 08 22 30 master screenshot 2018-10-16 at 08 26 51

@cpojer
Copy link
Member

cpojer commented Oct 16, 2018

I don’t think this works. In @thymikee‘s screenshot you can see the same test is printed both as passing and running at the same time. Terminal printing is weird.

@thymikee
Copy link
Collaborator

The same test being printed twice is a separated issue, we're probably tracking it somewhere, maybe @SimenB remembers

@thymikee
Copy link
Collaborator

I wonder if we could make it more deterministic by rendering this reporter with React: https://github.com/zamotany/react-slate.

@SimenB
Copy link
Member

SimenB commented Oct 16, 2018

Passing and running happens if something else writes to stderr while jest is doing it, see #6524. If it happens in other cases than that, I don't know if we track it or not.

rendering this reporter with React

+1, that'd be awesome!

@SimenB
Copy link
Member

SimenB commented Oct 16, 2018

@rogeliog you've played with fancy terminal rendering, thoughts here?

@Brantron
Copy link
Author

Brantron commented Oct 16, 2018

@thymikee @SimenB does the latest commit solve the issues described? It seems good on my end.

screen shot 2018-10-16 at 9 53 17 am

@Brantron
Copy link
Author

Any updates needed? I think this does the trick

@Brantron
Copy link
Author

Brantron commented Nov 2, 2018

hey folks, any outstanding reasons not to merge this? I believe all issues have been addressed?

@rickhanlonii
Copy link
Member

@aaronabramov what do you think?

@cpojer
Copy link
Member

cpojer commented Dec 2, 2018

As said, I tried the same thing in the past and it definitely led to issues.

* upstream/master: (391 commits)
  more precise circus asyncError types (jestjs#8150)
  Add typeahead watch plugin (jestjs#6449)
  fix: getTimerCount not taking immediates and ticks into account (jestjs#8139)
  website: add an additional filter predicate to backers (jestjs#7286)
  [🔥] Revised README (jestjs#8076)
  [jest-each] Fix test function type (jestjs#8145)
  chore: improve bug template labels for easier maintenance (jestjs#8141)
  Add documentation related to auto-mocking (jestjs#8099)
  Add support for bigint to pretty-format (jestjs#8138)
  Revert "Add fuzzing based tests in Jest (jestjs#8012)"
  chore: remove console.log
  chore: Improve description of optional arguments in ExpectAPI.md (jestjs#8126)
  Add fuzzing based tests in Jest (jestjs#8012)
  Move @types/node to the root package.json (jestjs#8129)
  chore: use property initializer syntax (jestjs#8117)
  chore: delete flow types from the repo (jestjs#8061)
  Move changelog entry to the proper version (jestjs#8115)
  Release 24.5.0
  Expose throwOnModuleCollision (jestjs#8113)
  add matchers to expect type (jestjs#8093)
  ...
@thymikee
Copy link
Collaborator

I've updated the PR to be even with master, but there newline is still there in watch mode.

@SimenB
Copy link
Member

SimenB commented Mar 19, 2019

Closing - I'm gonna try to rewrite our reporting to use Ink which handles this for us

@SimenB SimenB closed this Mar 19, 2019
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants