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

console.log is supressed when using --forceExit #2358

Closed
schovi opened this issue Dec 19, 2016 · 13 comments
Closed

console.log is supressed when using --forceExit #2358

schovi opened this issue Dec 19, 2016 · 13 comments
Labels

Comments

@schovi
Copy link

schovi commented Dec 19, 2016

bug

Having test like:

it('something', function() {
  console.log("I am from console.log")
  expect(true). toBeTruthy();
})

With command jest it will print

 PASS  tests/somethingjs
    ✓ something (27ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        3.848s
Ran all test suites matching "something".
  console.log tests/something.js:2
    I am from console.log

But when calling it like jest --forceExit it does not print any console.log output. We expent it to behave same as without --forceExit.

I tried 0.17.0 and 0.18.0, both with same result.

We use this flag, because on CI it wont end test process. Temporary solution is to have different taks on CI and local machine.

@thymikee
Copy link
Collaborator

I think this is pretty much connected: #2166

@thymikee
Copy link
Collaborator

Let's move the discussion there!

@mattkrick
Copy link

@thymikee this was not resolved by #2556. bumping the setTimeout to 100 fixes it, but that doesn't seem like an elegant solution. Can we re-open & discuss a proper fix?

@einnjo
Copy link

einnjo commented Apr 27, 2017

I'm seeing this exact same behavior in jest v19.0.2.

@jbdemonte
Copy link
Contributor

This problem seems to be still there in v22.4.2

@SimenB
Copy link
Member

SimenB commented Apr 4, 2018

Can someone provide a reproduction repo? If so, we'll reopen

@jbdemonte
Copy link
Contributor

jbdemonte commented Apr 4, 2018

@jbdemonte
Copy link
Contributor

As explained in the readme, this seems to be due to the async process

@SimenB
Copy link
Member

SimenB commented Apr 4, 2018

The issue here is that we have a timeout for flushing console logs in the default reporter: https://github.com/facebook/jest/blob/1eb02fd41ad6840350a5b2c0636151e2da8bcd8b/packages/jest-cli/src/reporters/default_reporter.js#L83-L86

Removing the setTimeout part prints the log in the correct place

#3895 tried to fix it, seems like it wasn't enough. Help appreciated!

EDIT: When running with --forceExit, onRunComplete is never called...

@SimenB SimenB reopened this Apr 4, 2018
@vinczedani
Copy link

vinczedani commented May 6, 2020

Any update on this issue?
I am seeing this today. jest version 24.9.0
Edit: updated jest to 26.0.1, same with this version

@github-actions
Copy link

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 30 days.

@github-actions github-actions bot added the Stale label Feb 26, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

This issue 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 Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants