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

print stack trace on calls to process.exit #6714

Merged
merged 5 commits into from Aug 8, 2018

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Jul 19, 2018

Summary

Currently jest just exits without any helpful info if process.exit is invoked from user-code.

See the following test file:

process.exit(1);

test('some test', async () => {
  await new Promise(resolve => setTimeout(resolve, 500));
})

It currently looks like this:
image

With the changes in this PR it looks like this:
image

I wanted to stick it along with the fake process.send from #5904, but to format the error I need config, and passing that through felt like meh. Can move it there, though?

Test plan

Integration test added

@@ -145,6 +146,28 @@ async function runTestInternal(
// For runtime errors
sourcemapSupport.install(sourcemapOptions);

const realExit = environment.global.process.exit;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if there's no process in global? We'll be calling undefined fn, or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's always there because of the installCommonGlobals call. Of course fully custom envs won't necessarily have it...

I can wrap it in an if

@codecov-io
Copy link

codecov-io commented Jul 19, 2018

Codecov Report

Merging #6714 into master will decrease coverage by 0.06%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6714      +/-   ##
==========================================
- Coverage   63.68%   63.62%   -0.07%     
==========================================
  Files         235      235              
  Lines        9003     9012       +9     
  Branches        4        4              
==========================================
  Hits         5734     5734              
- Misses       3268     3277       +9     
  Partials        1        1
Impacted Files Coverage Δ
packages/jest-runner/src/run_test.js 2.98% <0%> (-0.47%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf9cbc2...3b80f4a. Read the comment docs.

@aaronabramov aaronabramov merged commit 690450d into jestjs:master Aug 8, 2018
@SimenB SimenB deleted the handle-process-exit branch August 8, 2018 05:57
@SimenB SimenB mentioned this pull request Aug 8, 2018
thymikee added a commit to rhysawilliams2010/jest that referenced this pull request Aug 8, 2018
* upstream/master: (122 commits)
  fix: don't report promises as open handles (jestjs#6716)
  support serializing `DocumentFragment` (jestjs#6705)
  Allow test titles to include array index (jestjs#6414)
  fix `toContain` suggest to contain equal message (jestjs#6810)
  fix: testMatch not working with negations (jestjs#6648)
  Add test cases for jestjs#6744 (jestjs#6772)
  print stack trace on calls to process.exit (jestjs#6714)
  Updates SnapshotTesting.md to provide more info. on snapshot scope (jestjs#6735)
  Mark snapshots as obsolete when moved to an inline snapshot (jestjs#6773)
  [Docs] Clarified the use of literal values as property matchers in toMatchSnapshot() (jestjs#6807)
  Update CHANGELOG.md (jestjs#6799)
  fix changelog entry that is not in 23.4.2 (jestjs#6796)
  Fix --coverage with --findRelatedTests overwriting collectCoverageFrom options (jestjs#6736)
  Update testURL default value from about:blank to localhost (jestjs#6792)
  fix: `matchInlineSnapshot` when prettier dependencies are mocked (jestjs#6776)
  Fix retryTimes and add e2e regression test (jestjs#6762)
  Release v23.4.2
  Docs/ExpectAPI: Correct docs for `objectContaining` (jestjs#6754)
  chore(packages/babel-jest) readme (jestjs#6746)
  docs: noted --coverage aliased by --collectCoverage (jestjs#6741)
  ...
@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 12, 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.

None yet

5 participants