From 45cd2773a34ebcaf8c8ddbbe180def42dbed43af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Jim=C3=A9nez=20Es=C3=BAn?= Date: Wed, 2 May 2018 10:55:42 +0100 Subject: [PATCH] Revert #5945, as it introduces a memory leak (#6106) --- CHANGELOG.md | 2 - .../__snapshots__/globals.test.js.snap | 4 +- .../__tests__/stack_trace.test.js | 1 - packages/jest-jasmine2/src/index.js | 43 ++++++++----------- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 757423b966ef..729b99022783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,8 +93,6 @@ ([#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 diff --git a/integration-tests/__tests__/__snapshots__/globals.test.js.snap b/integration-tests/__tests__/__snapshots__/globals.test.js.snap index 56a97cf22209..7318ba3ca0a3 100644 --- a/integration-tests/__tests__/__snapshots__/globals.test.js.snap +++ b/integration-tests/__tests__/__snapshots__/globals.test.js.snap @@ -29,7 +29,7 @@ exports[`cannot test with no implementation 1`] = ` 1 | 2 | it('it', () => {}); > 3 | it('it, no implementation'); - | ^ + | ^ 4 | test('test, no implementation'); 5 | @@ -57,7 +57,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 | diff --git a/integration-tests/__tests__/stack_trace.test.js b/integration-tests/__tests__/stack_trace.test.js index 0457cb4104e0..c6a2d20b7bcd 100644 --- a/integration-tests/__tests__/stack_trace.test.js +++ b/integration-tests/__tests__/stack_trace.test.js @@ -22,7 +22,6 @@ 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/, ); diff --git a/packages/jest-jasmine2/src/index.js b/packages/jest-jasmine2/src/index.js index 9f144d349a9f..3e822d1420c8 100644 --- a/packages/jest-jasmine2/src/index.js +++ b/packages/jest-jasmine2/src/index.js @@ -17,7 +17,6 @@ import type Runtime from 'jest-runtime'; import path from 'path'; import fs from 'graceful-fs'; import {getCallsite} from 'jest-util'; -import sourcemapSupport from 'source-map-support'; import JasmineReporter from './reporter'; import {install as jasmineAsyncInstall} from './jasmine_async'; @@ -117,35 +116,29 @@ 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(sourcemapOptions); - - // For runtime errors - sourcemapSupport.install(sourcemapOptions); + .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; + }, + }); if (globalConfig.enabledTestsMap) { env.specFilter = spec => {