-
-
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.
- Loading branch information
1 parent
810115d
commit db0cb26
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/jest-runtime/src/__tests__/Runtime-sourceMaps-test.js
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,47 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails oncall+jsinfra | ||
*/ | ||
'use strict'; | ||
|
||
let createRuntime; | ||
|
||
describe('Runtime', () => { | ||
beforeEach(() => { | ||
createRuntime = require('createRuntime'); | ||
}); | ||
|
||
describe('requireModule', () => { | ||
it('installs source maps if available', () => | ||
createRuntime(__filename).then(runtime => { | ||
let hasThrown = false; | ||
const sum = runtime.requireModule( | ||
runtime.__mockRootPath, | ||
'./sourcemaps/out/throwing-mapped-fn.js', | ||
).sum; | ||
|
||
try { | ||
sum(); | ||
} catch (err) { | ||
hasThrown = true; | ||
/* eslint-disable max-len */ | ||
if (process.platform === 'win32') { | ||
expect(err.stack).toMatch( | ||
/^Error: throwing fn\s+at sum.+\\__tests__\\test_root\\sourcemaps\\throwing-mapped-fn.js:10:9/, | ||
); | ||
} else { | ||
expect(err.stack).toMatch( | ||
/^Error: throwing fn\s+at sum.+\/__tests__\/test_root\/sourcemaps\/throwing-mapped-fn.js:10:9/, | ||
); | ||
} | ||
/* eslint-enable max-len */ | ||
} | ||
expect(hasThrown).toBe(true); | ||
})); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/jest-runtime/src/__tests__/test_root/sourcemaps/out/throwing-mapped-fn.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
packages/jest-runtime/src/__tests__/test_root/sourcemaps/out/throwing-mapped-fn.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
packages/jest-runtime/src/__tests__/test_root/sourcemaps/throwing-mapped-fn.js
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,11 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
export function sum() { | ||
throw new Error('throwing fn'); | ||
} |