-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[RFC]: Rethinking reporters in Jest #7900
Comments
I think this is one of the most exciting and necessary changes to improve UX, especially combined with your PPS. Would love to help work on this. Is there a good way to manage the transition phase? Using an ink and a legacy non-ink reporter at the same time seems like it would be hard to deal with. |
If I'm not mistaken, Ink uses Outside of that, I've ran into similar problems with Boost's console, where reporters all need to write to a stream in parallel. I believe I solved the problem by supporting 2 modes for writing:
This requires all the writing logic to be handled in a single layer (the |
Yeah, I think it'd have to be opt-in (through config or just
Current version does, V2 (which is the one we'd use) does not: https://github.com/vadimdemedes/ink/blob/440b83140a8e16ddfc5ad1b01bdc156f09350aba/package.json#L40-L52. Not to say it won't have issue of course. I did not encounter that when testing (IIRC, this was back in early November, might've just forgotten) |
@SimenB Looks like they forked it: https://github.com/vadimdemedes/ink/blob/440b83140a8e16ddfc5ad1b01bdc156f09350aba/src/vendor/log-update.js But if you haven't run into any issues, then hopefully it's fine. |
Ah, fair enough! I'm not really married to the choice of ink (there's also e.g. The goal (at least my goal) here is to make it easier to create beautiful interfaces with Jest, and I think migrating to a system that allows people to use React components unlocks some super exciting possibilities. The exact implementation of that is really fuzzy 🙂 EDIT: webpack-dashboard migrated to |
Agreed! Hopefully it works :P |
@SimenB glad you were able to finish the PR, really happy to see it! As I've said before, let me know if you run into any issues!
@milesj That is correct, Ink uses To work around this limitation, Ink has a |
Sorta related: #3160 |
@vadimdemedes Yup ran into similar issues when implementing my console. That Jest POC is pretty slick, love it 👍 |
The underlying In celebration, I merged in master into my branch (almost worked 😅). Will be taking a look at this in a couple of weeks 🙂 |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
I still want to do this, work is ongoing (albeit stalled 😅) in https://github.com/jest-community/jest-react-reporter. Any and all help welcome! |
This is all very ambitions, but IMO want a less sophisticated reporter. Like one that just lets me console.log and have it appear. Jest makes debugging slow tests/infinite loops is really really hard. I haven't had that issue with other test frameworks, likely because they didn't get fancy about stdout. |
I find that jest reporter is overwriting/hiding STDERR output that comes from a native add on. This makes it hard to debug this I have to repeat the logs several times in the native addon to avoid jest reporter clobbering the stderr output. |
Reporters (that want to print to
stdout
) in Jest are pretty advanced as they have to replace existing text to show status (both per test and for the total run), they have to handle test results coming in out of order due to parallelized test execution and they have to print log output, assertion errors etc.. All of this has to look smooth with nice colors both on local machines and on CI.Jest currently has 3 (4) built-in reporters: standard, verbose and coverage (the fourth being a Notify reporter, but that doesn't write to stdout). Those 3 reporters are implemented by a cool 2941 lines of code according to
cloc
. Source code lives here.Implementation wise, a reporter currently have to implement an interface (documented here) where functions are called whenever an event happens (such as
onRunStart
,onTestResult
etc.).The problem with the current way reporters are implemented, is that they all have to print to
process.stdout
manually, dealing with whether or not it's interactive, clearing (or not) stale output. This is a hard thing to get right (e.g. #1781 is 2.5 years old). And you cannot really have multiple reporters working at the same time - they will trip each other up as there's no way to synchronize writes to the stream.I'd love to be able to offload a lot of the work these reporters currently do to something better suited for building reactive UIs - React. We would then just re-render with new props whenever we have new state, React would give us how it's supposed to look, and we could offload to
ink
to actually render the output in the terminal.Jest itself could also expose all the different parts of its default reporter (a few quick screenshots below) as React components, making it easier to build a custom reporters.
What do people think?
I currently have a working prototype implementation of Jest's current reporters using Ink here.
/cc @vadimdemedes
PS: Reporters that just want to write to a file and not
stdout
(e.g.jest-junit
or the built-in Notify reporter) would not be affected by this change.PPS: It might make sense to make it easier writing watch plugins in
ink
as well (if it's hard, I haven't tested), but that's out of scope.The text was updated successfully, but these errors were encountered: