Skip to content
Prev Previous commit
Next Next commit
Install source-map-support into jasmine runtime
  • Loading branch information
felipeochoa committed Oct 4, 2017
commit fffc59bf33c9da2899ac7a5206ce4c966ab9bba3
20 changes: 20 additions & 0 deletions packages/jest-jasmine2/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {TestResult} from 'types/TestResult';
import type Runtime from 'jest-runtime';

import path from 'path';
import fs from 'fs';
import JasmineReporter from './reporter';
import {install as jasmineAsyncInstall} from './jasmine_async';

Expand Down Expand Up @@ -93,6 +94,25 @@ async function jasmine2(
runtime.requireModule(config.setupTestFrameworkScriptFile);
}

runtime
.requireModule(require.resolve('source-map-support'), 'source-map-support')
.install({
handleUncaughtExceptions: false,
retrieveSourceMap: source => {
if (runtime._sourceMapRegistry[source]) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think accessing a private field of runtime should be done here :)

try {
return {
map: JSON.parse(
fs.readFileSync(runtime._sourceMapRegistry[source]),
),
url: source,
};
} catch (e) {}
}
return null;
},
});

if (globalConfig.testNamePattern) {
const testNameRegex = new RegExp(globalConfig.testNamePattern, 'i');
env.specFilter = spec => testNameRegex.test(spec.getFullName());
Expand Down