-
-
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
Add --detectOpenHandles
flag
#6130
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2a74f80
why-running
SimenB 4a7f44a
add --detectOpenHandles flag
SimenB b6f7276
move processing of w-i-n-r into separate function
SimenB 74f0006
pretty-print open handles
SimenB 2950383
docs
SimenB 2dfa609
update snapshots
SimenB 11b0434
ensure empty when flag not used
SimenB c07c9e3
please flow gods
SimenB ce04b4d
add pretty colors
SimenB 2e19046
less if
SimenB eaaf3a5
use pluralize
SimenB fd2dd3a
Revert "less if"
SimenB dc55ef1
extract formatting of why-running
SimenB 93217dc
cmon flow, be nice
SimenB bf5e587
use code frame
SimenB 1b15451
Implement async_hooks manually
SimenB a3ea1aa
nudge users towards new feature
SimenB a67c258
make handlers better match other error output
SimenB 82595e3
add tests
SimenB b4cf302
PR feeback
SimenB 1c8c356
really fic PR feedback
SimenB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
integration-tests/__tests__/__snapshots__/detect_open_handles.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`prints message about flag on forceExit 1`] = ` | ||
"Force exiting Jest | ||
|
||
Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?" | ||
`; | ||
|
||
exports[`prints message about flag on slow tests 1`] = ` | ||
"Jest did not exit one second after the test run has completed. | ||
|
||
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with \`--detectOpenHandles\` to troubleshoot this issue." | ||
`; | ||
|
||
exports[`prints out info about open handlers 1`] = ` | ||
"Jest has detected the following 1 open handle potentially keeping Jest from exiting: | ||
|
||
● GETADDRINFOREQWRAP | ||
|
||
5 | const app = new http.Server(); | ||
6 | | ||
> 7 | app.listen({host: 'localhost', port: 0}); | ||
| ^ | ||
8 | | ||
|
||
at Object.<anonymous> (server.js:7:5) | ||
at Object.<anonymous> (__tests__/test.js:3:1)" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
const runJest = require('../runJest'); | ||
|
||
try { | ||
// $FlowFixMe: Node core | ||
require('async_hooks'); | ||
} catch (e) { | ||
if (e.code === 'MODULE_NOT_FOUND') { | ||
// eslint-disable-next-line jest/no-focused-tests | ||
fit('skip test for unsupported nodes', () => { | ||
console.warn('Skipping test for node ' + process.version); | ||
}); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
|
||
function getTextAfterTest(stderr) { | ||
return stderr.split('Ran all test suites.')[1].trim(); | ||
} | ||
|
||
it('prints message about flag on slow tests', async () => { | ||
const {stderr} = await runJest.until( | ||
'detect-open-handles', | ||
[], | ||
'Jest did not exit one second after the test run has completed.', | ||
); | ||
const textAfterTest = getTextAfterTest(stderr); | ||
|
||
expect(textAfterTest).toMatchSnapshot(); | ||
}); | ||
|
||
it('prints message about flag on forceExit', async () => { | ||
const {stderr} = await runJest.until( | ||
'detect-open-handles', | ||
['--forceExit'], | ||
'Force exiting Jest', | ||
); | ||
const textAfterTest = getTextAfterTest(stderr); | ||
|
||
expect(textAfterTest).toMatchSnapshot(); | ||
}); | ||
|
||
it('prints out info about open handlers', async () => { | ||
const {stderr} = await runJest.until( | ||
'detect-open-handles', | ||
['--detectOpenHandles'], | ||
'Jest has detected', | ||
); | ||
const textAfterTest = getTextAfterTest(stderr); | ||
|
||
expect(textAfterTest).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require('../server'); | ||
|
||
test('something', () => { | ||
expect(true).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const http = require('http'); | ||
|
||
const app = new http.Server(); | ||
|
||
app.listen({host: 'localhost', port: 0}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that there is sometimes output after the summary, this needs to be more precise