-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent a ENOENT crash by checking for file existence in jest-message…
…-util (#5405) * Prevent a ENOENT crash by checking for existence Jest tries to load the stack-trace based on the top frame. The problem is, the filename may be provided by the source-map, which is unreliable since it can point to a non-existent file. In such a case, the code would cause a hard crash of "Test suite failed to run" with a stack-trace pointing at "exports.formatStackTrace", which I have corrected here. * add an integration test for bad-source-map case * lint CHANGELOG * use a try-catch rather than fs.existsSync
- Loading branch information
Showing
6 changed files
with
65 additions
and
15 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* 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'); | ||
|
||
test('suite with test cases that contain malformed sourcemaps', () => { | ||
const result = runJest('bad-source-map'); | ||
expect(result.stderr).not.toMatch('ENOENT'); | ||
}); |
15 changes: 15 additions & 0 deletions
15
integration-tests/bad-source-map/__tests__/bad-source-map.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
integration-tests/bad-source-map/__tests__/bad-source-map.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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