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

Running tests in verbose mode with console logging breaks output #4

Open
jeysal opened this issue Nov 13, 2019 · 5 comments
Open

Running tests in verbose mode with console logging breaks output #4

jeysal opened this issue Nov 13, 2019 · 5 comments
Labels
bug Something isn't working upstream parity

Comments

@jeysal
Copy link
Member

jeysal commented Nov 13, 2019

image

Repro: https://github.com/yldio/yld.io/tree/38514750c72574747c96de405ab0ec174b75692d

yarn add -D [email protected]
yarn test add-frontmatter --reporters=jest-react-reporter 

It also does not show test case details like the default reporter, not sure if it is supposed to do that.

@SimenB
Copy link
Member

SimenB commented Nov 13, 2019

It also does not show test case details like the default reporter, not sure if it is supposed to do that.

It's supposed to work the exact same, at least for a first iteration. Could you open up a separate issue for it? Or send a PR 🙂

Opened one up: #6

@SimenB SimenB added bug Something isn't working upstream parity labels Nov 13, 2019
@SimenB
Copy link
Member

SimenB commented Nov 14, 2019

Haven't tried, but I'm wondering if it's related to vadimdemedes/ink#162

@SimenB
Copy link
Member

SimenB commented Nov 14, 2019

Testing now, it's something to do with @testing-library/react's async act warning (just a console.error). Deleting that line from node_modules fixes the issue. Not sure why it's not properly intercepted...

@SimenB SimenB changed the title running one test file causes leftover lines Running tests in verbose mode with console logging breaks output Nov 16, 2019
@SimenB
Copy link
Member

SimenB commented Nov 16, 2019

Figured out what's going on, although I have no idea how to fix it...

The issue is that, since we're only running a single test, Jest switches into verbose mode: https://github.com/facebook/jest/blob/18dfcbb41965a6c2682e1235b5f76dd071be24a1/packages/jest-core/src/runJest.ts#L231. Since we're verbose, we use the custom console instead of the buffered one: https://github.com/facebook/jest/blob/18dfcbb41965a6c2682e1235b5f76dd071be24a1/packages/jest-runner/src/runTest.ts#L135-L141. This console writes directly to stderr on log messages, rather than buffering them and relying on the reporter to print it: https://github.com/facebook/jest/blob/18dfcbb41965a6c2682e1235b5f76dd071be24a1/packages/jest-console/src/CustomConsole.ts#L46-L51

There is jestjs/jest#6441 which we should do, but it'll cause log entries to be printed twice... I think the only proper way to solve this is to land jestjs/jest#9001 and also stream individual console entries as they happen.

We don't wanna force people to use the buffered logger, since e.g. tests that time out or hang forever would not get any logging out.

Thoughts? /cc @thymikee @rogeliog

Edit: It means vadimdemedes/ink#162 would help, but I think the issue lies with Jest itself and allowing a stream of data rather than just complete test results should allow us to fix this.

@rogeliog
Copy link
Member

Yes, I agree that we might need something like jestjs/jest#9001 and jestjs/jest#6441 would make sense for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream parity
Projects
None yet
Development

No branches or pull requests

3 participants