Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove type casts
  • Loading branch information
SimenB committed Feb 26, 2019
commit 2ffbbebc2fef95eee766e519bb186ded79a4e645
17 changes: 6 additions & 11 deletions e2e/runJest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import path from 'path';
import fs from 'fs';
import execa, {ExecaChildProcess, ExecaChildPromise, ExecaReturns} from 'execa';
import execa, {ExecaChildProcess, ExecaReturns} from 'execa';
import {Writable} from 'readable-stream';
import stripAnsi from 'strip-ansi';
import {normalizeIcons} from './Utils';
Expand Down Expand Up @@ -44,15 +44,15 @@ function spawnJest(
args?: Array<string>,
options?: RunJestOptions,
spawnAsync?: true,
): ExecaChildPromise;
): ExecaChildProcess;

// Spawns Jest and returns either a Promise (if spawnAsync is true) or the completed child process
function spawnJest(
dir: string,
args?: Array<string>,
options: RunJestOptions = {},
spawnAsync: boolean = false,
): ExecaReturns | ExecaChildPromise {
): ExecaReturns | ExecaChildProcess {
const isRelative = !path.isAbsolute(dir);

if (isRelative) {
Expand Down Expand Up @@ -103,9 +103,9 @@ function normalizeResult(result: RunJestResult, options: RunJestOptions) {
// For compat with cross-spawn
result.status = result.code;

result.stdout = normalizeIcons(result.stdout as string);
result.stdout = normalizeIcons(result.stdout);
if (options.stripAnsi) result.stdout = stripAnsi(result.stdout);
result.stderr = normalizeIcons(result.stderr as string);
result.stderr = normalizeIcons(result.stderr);
if (options.stripAnsi) result.stderr = stripAnsi(result.stderr);

return result;
Expand Down Expand Up @@ -144,12 +144,7 @@ export const until = async function(
text: string,
options: RunJestOptions = {},
) {
const jestPromise = spawnJest(
dir,
args,
{timeout: 30000, ...options},
true,
) as ExecaChildProcess;
const jestPromise = spawnJest(dir, args, {timeout: 30000, ...options}, true);

jestPromise.stderr.pipe(
new Writable({
Expand Down