Skip to content

Commit 6d0c0f0

Browse files
mjesuncpojer
authored andcommitted
Revert "Re-inject native Node modules" (#5009)
* 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.
1 parent ea3fabc commit 6d0c0f0

File tree

16 files changed

+58
-316
lines changed

16 files changed

+58
-316
lines changed

integration_tests/__tests__/leak_detection.test.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

integration_tests/__tests__/require_all_modules.test.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

integration_tests/leak-detection/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

integration_tests/leak-detection/test.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

integration_tests/require-all-modules/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

integration_tests/require-all-modules/test.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

jest-inspect

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/jest-editor-support/src/__tests__/runner.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ const {readFileSync} = require('fs');
1515
const fixtures = path.resolve(__dirname, '../../../../fixtures');
1616
import ProjectWorkspace from '../project_workspace';
1717

18-
// Win32 requires to spawn a process to kill the first one, by using "taskkill".
19-
// Mocking "child_process" avoids the async spawn.
20-
jest.mock('child_process');
21-
2218
// Replace `readFile` with `readFileSync` so we don't get multiple threads
2319
jest.doMock('fs', () => {
2420
return {

packages/jest-jasmine2/src/index.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,10 @@ const JASMINE = require.resolve('./jasmine/jasmine_light.js');
2525
async function jasmine2(
2626
globalConfig: GlobalConfig,
2727
config: ProjectConfig,
28-
environment: ?Environment,
28+
environment: Environment,
2929
runtime: Runtime,
3030
testPath: string,
3131
): Promise<TestResult> {
32-
// The "environment" parameter is nullable just so that we can clean its
33-
// reference after adding some variables to it; but you still need to pass
34-
// it when calling "jasmine2".
35-
if (!environment) {
36-
throw new ReferenceError('Please pass a valid Jest Environment object');
37-
}
38-
3932
const reporter = new JasmineReporter(
4033
globalConfig,
4134
config,
@@ -92,17 +85,12 @@ async function jasmine2(
9285
if (config.resetMocks) {
9386
runtime.resetAllMocks();
9487

95-
if (environment && config.timers === 'fake') {
88+
if (config.timers === 'fake') {
9689
environment.fakeTimers.useFakeTimers();
9790
}
9891
}
9992
});
10093

101-
// Free references to environment to avoid leaks.
102-
env.afterAll(() => {
103-
environment = null;
104-
});
105-
10694
env.addReporter(reporter);
10795

10896
runtime
@@ -126,9 +114,7 @@ async function jasmine2(
126114

127115
if (config.setupTestFramework && config.setupTestFramework.length) {
128116
config.setupTestFramework.forEach(module => {
129-
if (environment) {
130-
require(module)(environment.global);
131-
}
117+
require(module)(environment.global);
132118
});
133119
}
134120

packages/jest-message-util/src/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ type StackTraceOptions = {
4040
// filter for noisy stack trace lines
4141
const JASMINE_IGNORE = /^\s+at(?:(?:.*?vendor\/|jasmine\-)|\s+jasmine\.buildExpectationResult)/;
4242
const JEST_INTERNALS_IGNORE = /^\s+at.*?jest(-.*?)?(\/|\\)(build|node_modules|packages)(\/|\\)/;
43-
44-
const JEST_NODE_NATIVE_IGNORE = /^\s+at.*?jest-node-native-/;
4543
const ANONYMOUS_FN_IGNORE = /^\s+at <anonymous>.*$/;
4644
const ANONYMOUS_PROMISE_IGNORE = /^\s+at (new )?Promise \(<anonymous>\).*$/;
4745
const ANONYMOUS_GENERATOR_IGNORE = /^\s+at Generator.next \(<anonymous>\).*$/;
@@ -140,10 +138,6 @@ const removeInternalStackEntries = (lines, options: StackTraceOptions) => {
140138
return false;
141139
}
142140

143-
if (JEST_NODE_NATIVE_IGNORE.test(line)) {
144-
return false;
145-
}
146-
147141
if (!STACK_PATH_REGEXP.test(line)) {
148142
return true;
149143
}

packages/jest-runner/src/run_test.js

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ async function runTestInternal(
7474
RuntimeClass,
7575
>);
7676

77-
let environment = new TestEnvironment(config);
78-
77+
const environment = new TestEnvironment(config);
7978
const leakDetector = config.detectLeaks
8079
? new LeakDetector(environment)
8180
: null;
@@ -99,24 +98,15 @@ async function runTestInternal(
9998
testConsole = new BufferedConsole();
10099
}
101100

102-
let cacheFS = {[path]: testSource};
101+
const cacheFS = {[path]: testSource};
103102
setGlobal(environment.global, 'console', testConsole);
104103

105-
const coverageOptions = {
104+
const runtime = new Runtime(config, environment, resolver, cacheFS, {
106105
collectCoverage: globalConfig.collectCoverage,
107106
collectCoverageFrom: globalConfig.collectCoverageFrom,
108107
collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom,
109108
mapCoverage: globalConfig.mapCoverage,
110-
};
111-
112-
let runtime = new Runtime(
113-
config,
114-
environment,
115-
resolver,
116-
cacheFS,
117-
coverageOptions,
118-
path,
119-
);
109+
});
120110

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

132+
if (globalConfig.logHeapUsage) {
133+
if (global.gc) {
134+
global.gc();
135+
}
136+
result.memoryUsage = process.memoryUsage().heapUsed;
137+
}
138+
142139
// Delay the resolution to allow log messages to be output.
143140
return new Promise(resolve => {
144141
setImmediate(() => resolve({leakDetector, result}));
145142
});
146143
} finally {
147-
if (environment.teardown) {
148-
await environment.teardown();
149-
}
150-
151-
if (runtime.reset) {
152-
await runtime.reset();
153-
}
154-
155-
// Free references to environment to avoid leaks.
156-
cacheFS = null;
157-
environment = null;
158-
runtime = null;
144+
await environment.teardown();
159145
}
160146
}
161147

@@ -172,11 +158,6 @@ export default async function runTest(
172158
resolver,
173159
);
174160

175-
if (globalConfig.logHeapUsage) {
176-
global.gc && global.gc();
177-
result.memoryUsage = process.memoryUsage().heapUsed;
178-
}
179-
180161
// Resolve leak detector, outside the "runTestInternal" closure.
181162
result.leaks = leakDetector ? leakDetector.isLeaking() : false;
182163

0 commit comments

Comments
 (0)