Skip to content

Commit

Permalink
Revert "Re-inject native Node modules" (#5009)
Browse files Browse the repository at this point in the history
* Revert "docs: update expect.anything() example (#5007)"

This reverts commit ea3fabc.

* Revert "Emphasise required return (#4999)"

This reverts commit 4f1113c.

* Revert "Makes NPM a link like Yarn is (#4998)"

This reverts commit aa4f09d.

* Revert "Update Timeout error message to `jest.timeout` and display current timeout value (#4990)"

This reverts commit 08f8394.

* Revert "fix: jest-util should not depend on jest-mock (#4992)"

This reverts commit 4e2f41f.

* Revert "Update Troubleshooting.md (#4988)"

This reverts commit 6414f28.

* Revert "Revert "Add the Yammer logo to the 'who is using this' section of the website." (#4987)"

This reverts commit 91b104f.

* Revert "Make "weak" optional dependency and check it at runtime (#4984)"

This reverts commit e00529d.

* Revert "Re-inject native Node modules (#4970)"

This reverts commit ef55e89.
  • Loading branch information
mjesun authored and cpojer committed Dec 4, 2017
1 parent ea3fabc commit 6d0c0f0
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 316 deletions.
17 changes: 0 additions & 17 deletions integration_tests/__tests__/leak_detection.test.js

This file was deleted.

21 changes: 0 additions & 21 deletions integration_tests/__tests__/require_all_modules.test.js

This file was deleted.

5 changes: 0 additions & 5 deletions integration_tests/leak-detection/package.json

This file was deleted.

27 changes: 0 additions & 27 deletions integration_tests/leak-detection/test.js

This file was deleted.

5 changes: 0 additions & 5 deletions integration_tests/require-all-modules/package.json

This file was deleted.

18 changes: 0 additions & 18 deletions integration_tests/require-all-modules/test.js

This file was deleted.

9 changes: 0 additions & 9 deletions jest-inspect

This file was deleted.

4 changes: 0 additions & 4 deletions packages/jest-editor-support/src/__tests__/runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ const {readFileSync} = require('fs');
const fixtures = path.resolve(__dirname, '../../../../fixtures');
import ProjectWorkspace from '../project_workspace';

// Win32 requires to spawn a process to kill the first one, by using "taskkill".
// Mocking "child_process" avoids the async spawn.
jest.mock('child_process');

// Replace `readFile` with `readFileSync` so we don't get multiple threads
jest.doMock('fs', () => {
return {
Expand Down
20 changes: 3 additions & 17 deletions packages/jest-jasmine2/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,10 @@ const JASMINE = require.resolve('./jasmine/jasmine_light.js');
async function jasmine2(
globalConfig: GlobalConfig,
config: ProjectConfig,
environment: ?Environment,
environment: Environment,
runtime: Runtime,
testPath: string,
): Promise<TestResult> {
// The "environment" parameter is nullable just so that we can clean its
// reference after adding some variables to it; but you still need to pass
// it when calling "jasmine2".
if (!environment) {
throw new ReferenceError('Please pass a valid Jest Environment object');
}

const reporter = new JasmineReporter(
globalConfig,
config,
Expand Down Expand Up @@ -92,17 +85,12 @@ async function jasmine2(
if (config.resetMocks) {
runtime.resetAllMocks();

if (environment && config.timers === 'fake') {
if (config.timers === 'fake') {
environment.fakeTimers.useFakeTimers();
}
}
});

// Free references to environment to avoid leaks.
env.afterAll(() => {
environment = null;
});

env.addReporter(reporter);

runtime
Expand All @@ -126,9 +114,7 @@ async function jasmine2(

if (config.setupTestFramework && config.setupTestFramework.length) {
config.setupTestFramework.forEach(module => {
if (environment) {
require(module)(environment.global);
}
require(module)(environment.global);
});
}

Expand Down
6 changes: 0 additions & 6 deletions packages/jest-message-util/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ type StackTraceOptions = {
// filter for noisy stack trace lines
const JASMINE_IGNORE = /^\s+at(?:(?:.*?vendor\/|jasmine\-)|\s+jasmine\.buildExpectationResult)/;
const JEST_INTERNALS_IGNORE = /^\s+at.*?jest(-.*?)?(\/|\\)(build|node_modules|packages)(\/|\\)/;

const JEST_NODE_NATIVE_IGNORE = /^\s+at.*?jest-node-native-/;
const ANONYMOUS_FN_IGNORE = /^\s+at <anonymous>.*$/;
const ANONYMOUS_PROMISE_IGNORE = /^\s+at (new )?Promise \(<anonymous>\).*$/;
const ANONYMOUS_GENERATOR_IGNORE = /^\s+at Generator.next \(<anonymous>\).*$/;
Expand Down Expand Up @@ -140,10 +138,6 @@ const removeInternalStackEntries = (lines, options: StackTraceOptions) => {
return false;
}

if (JEST_NODE_NATIVE_IGNORE.test(line)) {
return false;
}

if (!STACK_PATH_REGEXP.test(line)) {
return true;
}
Expand Down
43 changes: 12 additions & 31 deletions packages/jest-runner/src/run_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ async function runTestInternal(
RuntimeClass,
>);

let environment = new TestEnvironment(config);

const environment = new TestEnvironment(config);
const leakDetector = config.detectLeaks
? new LeakDetector(environment)
: null;
Expand All @@ -99,24 +98,15 @@ async function runTestInternal(
testConsole = new BufferedConsole();
}

let cacheFS = {[path]: testSource};
const cacheFS = {[path]: testSource};
setGlobal(environment.global, 'console', testConsole);

const coverageOptions = {
const runtime = new Runtime(config, environment, resolver, cacheFS, {
collectCoverage: globalConfig.collectCoverage,
collectCoverageFrom: globalConfig.collectCoverageFrom,
collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom,
mapCoverage: globalConfig.mapCoverage,
};

let runtime = new Runtime(
config,
environment,
resolver,
cacheFS,
coverageOptions,
path,
);
});

const start = Date.now();
await environment.setup();
Expand All @@ -139,23 +129,19 @@ async function runTestInternal(
result.skipped = testCount === result.numPendingTests;
result.displayName = config.displayName;

if (globalConfig.logHeapUsage) {
if (global.gc) {
global.gc();
}
result.memoryUsage = process.memoryUsage().heapUsed;
}

// Delay the resolution to allow log messages to be output.
return new Promise(resolve => {
setImmediate(() => resolve({leakDetector, result}));
});
} finally {
if (environment.teardown) {
await environment.teardown();
}

if (runtime.reset) {
await runtime.reset();
}

// Free references to environment to avoid leaks.
cacheFS = null;
environment = null;
runtime = null;
await environment.teardown();
}
}

Expand All @@ -172,11 +158,6 @@ export default async function runTest(
resolver,
);

if (globalConfig.logHeapUsage) {
global.gc && global.gc();
result.memoryUsage = process.memoryUsage().heapUsed;
}

// Resolve leak detector, outside the "runTestInternal" closure.
result.leaks = leakDetector ? leakDetector.isLeaking() : false;

Expand Down
Loading

0 comments on commit 6d0c0f0

Please sign in to comment.