Skip to content

Commit

Permalink
no promisify
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 7, 2020
1 parent 8875e32 commit 0c3d1e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/jest-core/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ const runWithoutWatch = async (
changedFilesPromise?: ChangedFilesPromise,
filter?: Filter,
) => {
const startRun = async (): Promise<void | null> => {
const startRun = async (): Promise<void> => {
if (!globalConfig.listTests) {
preRunMessagePrint(outputStream);
}
return runJest({
await runJest({
changedFilesPromise,
contexts,
failedTestsCache: undefined,
Expand Down
8 changes: 3 additions & 5 deletions packages/jest-core/src/runJest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import * as path from 'path';
import {promisify} from 'util';
import chalk = require('chalk');
import {CustomConsole} from '@jest/console';
import {interopRequireDefault, tryRealpath} from 'jest-util';
Expand Down Expand Up @@ -76,8 +75,6 @@ type ProcessResultOptions = Pick<
outputStream: NodeJS.WriteStream;
};

const wait = promisify(setTimeout);

async function createOpenHandlesResult(
collectHandles: (keepOpen: boolean) => Array<Error>,
): Promise<Array<OpenHandleError>> {
Expand All @@ -86,7 +83,8 @@ async function createOpenHandlesResult(
const handlesBeforeStack = handlesBeforeWait.map(handle => handle.stack);

// wait 100ms to allow some handles to be cleaned up, including Jest's internal timeouts
await wait(100);
// make sure _not_ to unref it, otherwise the promise won't actually be waited for if there's nothing else to do
await new Promise(resolve => setTimeout(resolve, 100));

const handlesAfterWait = collectHandles(false);
const handlesAfterStack = handlesAfterWait.map(handle => handle.stack);
Expand Down Expand Up @@ -153,7 +151,7 @@ async function processResults(
}

if (onComplete) {
onComplete(runResults);
await onComplete(runResults);
}
}

Expand Down

0 comments on commit 0c3d1e3

Please sign in to comment.