Skip to content

Commit

Permalink
fix --logHeapUsage (jestjs#4176)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov authored and cpojer committed Aug 2, 2017
1 parent 34aa5c8 commit 3f175f4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions integration_tests/__tests__/log_heap_usage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/

'use strict';

const path = require('path');
const os = require('os');
const skipOnWindows = require('../../scripts/skip_on_windows');
const {cleanup, writeFiles} = require('../utils');
const runJest = require('../runJest');

const DIR = path.resolve(os.tmpdir(), 'log_heap_usage_test');

skipOnWindows.suite();

beforeEach(() => cleanup(DIR));
afterAll(() => cleanup(DIR));

test('logs memory usage', () => {
writeFiles(DIR, {
'__tests__/a-banana.js': `test('banana', () => expect(1).toBe(1));`,
'package.json': JSON.stringify({jest: {testEnvironment: 'node'}}),
});

const {stderr} = runJest(DIR, ['--logHeapUsage']);
expect(stderr).toMatch(/PASS\s{2}__tests__\/a-banana.js.*\d+ MB heap size/);
});
2 changes: 1 addition & 1 deletion packages/jest-cli/src/run_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function runTest(
result =>
Promise.resolve().then(() => {
environment.dispose();
if (config.logHeapUsage) {
if (globalConfig.logHeapUsage) {
if (global.gc) {
global.gc();
}
Expand Down

0 comments on commit 3f175f4

Please sign in to comment.