Skip to content
/ jest Public
forked from jestjs/jest

Commit

Permalink
Revert "Revert jestjs#5945, as it introduces a memory leak (jestjs#6106
Browse files Browse the repository at this point in the history
…)"

This reverts commit 45cd277.
  • Loading branch information
SimenB committed May 13, 2018
1 parent 753ae9b commit eb3d77e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
([#5888](https://github.com/facebook/jest/pull/5888))
* `[jest-mock]` [**BREAKING**] Replace timestamps with `invocationCallOrder`
([#5867](https://github.com/facebook/jest/pull/5867))
* `[jest-jasmine2]` Install `sourcemap-support` into normal runtime to catch
runtime errors ([#5945](https://github.com/facebook/jest/pull/5945))
* `[jest-jasmine2]` Added assertion error handling inside `afterAll hook`
([#5884](https://github.com/facebook/jest/pull/5884))
* `[jest-cli]` Remove the notifier actions in case of failure when not in watch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`cannot test with no implementation 1`] = `
1 |
2 | it('it', () => {});
> 3 | it('it, no implementation');
| ^
| ^
4 | test('test, no implementation');
5 |
Expand Down Expand Up @@ -56,7 +56,7 @@ exports[`cannot test with no implementation with expand arg 1`] = `
1 |
2 | it('it', () => {});
> 3 | it('it, no implementation');
| ^
| ^
4 | test('test, no implementation');
5 |
Expand Down
1 change: 1 addition & 0 deletions integration-tests/__tests__/stack_trace.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('Stack Trace', () => {
expect(stderr).toMatch(
/ReferenceError: thisIsARuntimeError is not defined/,
);
expect(stderr).toMatch(/> 10 \| thisIsARuntimeError\(\);/);
expect(stderr).toMatch(
/\s+at\s(?:.+?)\s\(__tests__\/runtime_error.test\.js/,
);
Expand Down
43 changes: 25 additions & 18 deletions packages/jest-jasmine2/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import path from 'path';
import fs from 'graceful-fs';
import installEach from './each';
import {getCallsite} from 'jest-util';
import sourcemapSupport from 'source-map-support';
import JasmineReporter from './reporter';
import {install as jasmineAsyncInstall} from './jasmine_async';

Expand Down Expand Up @@ -119,29 +120,35 @@ async function jasmine2(
runtime.requireModule(config.setupTestFrameworkScriptFile);
}

const sourcemapOptions = {
environment: 'node',
handleUncaughtExceptions: false,
retrieveSourceMap: source => {
const sourceMaps = runtime.getSourceMaps();
const sourceMapSource = sourceMaps && sourceMaps[source];

if (sourceMapSource) {
try {
return {
map: JSON.parse(fs.readFileSync(sourceMapSource)),
url: source,
};
} catch (e) {}
}
return null;
},
};

// For tests
runtime
.requireInternalModule(
require.resolve('source-map-support'),
'source-map-support',
)
.install({
environment: 'node',
handleUncaughtExceptions: false,
retrieveSourceMap: source => {
const sourceMaps = runtime.getSourceMaps();
const sourceMapSource = sourceMaps && sourceMaps[source];

if (sourceMapSource) {
try {
return {
map: JSON.parse(fs.readFileSync(sourceMapSource)),
url: source,
};
} catch (e) {}
}
return null;
},
});
.install(sourcemapOptions);

// For runtime errors
sourcemapSupport.install(sourcemapOptions);

if (globalConfig.enabledTestsMap) {
env.specFilter = spec => {
Expand Down

0 comments on commit eb3d77e

Please sign in to comment.