diff --git a/jest/helpers.ts b/jest/helpers.ts index 20f1ed003..3b19322b3 100644 --- a/jest/helpers.ts +++ b/jest/helpers.ts @@ -5,7 +5,6 @@ import {createDirectory} from 'jest-util'; import execa from 'execa'; import chalk from 'chalk'; import slash from 'slash'; -import {Writable} from 'readable-stream'; const CLI_PATH = path.resolve(__dirname, '../packages/cli/build/bin.js'); @@ -32,38 +31,6 @@ export function runCLI( }); } -// Runs cli until a given output is achieved, then kills it with `SIGTERM` -export async function runUntil( - dir: string, - args: string[] | undefined, - text: string, - options: RunOptions = { - expectedFailure: false, - }, -) { - const spawnPromise = spawnScriptAsync(dir, args || [], { - timeout: 30000, - cwd: dir, - ...options, - }); - - spawnPromise.stderr?.pipe( - new Writable({ - write(chunk: any, _encoding: string, callback: () => void) { - const output = chunk.toString('utf8'); - - if (output.includes(text)) { - spawnPromise.kill(); - } - - callback(); - }, - }), - ); - - return spawnPromise; -} - export const makeTemplate = (str: string): ((values?: Array) => string) => (values?: Array) => @@ -133,7 +100,7 @@ type SpawnFunction = ( options: SpawnOptions, ) => T; -export const spawnScript: SpawnFunction = ( +export const spawnScript: SpawnFunction> = ( execPath, args, options, @@ -145,19 +112,6 @@ export const spawnScript: SpawnFunction = ( return result; }; -const spawnScriptAsync: SpawnFunction = ( - execPath, - args, - options, -) => { - try { - return execa(execPath, args, getExecaOptions(options)); - } catch (result) { - handleTestFailure(execPath, options, result, args); - return result; - } -}; - function getExecaOptions(options: SpawnOptions) { const isRelative = !path.isAbsolute(options.cwd); diff --git a/package.json b/package.json index dbd444a65..2f9361d00 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "@types/jest": "^26.0.15", "@types/node": "^18.0.0", "@types/node-fetch": "^2.3.7", - "@types/readable-stream": "^2.3.0", "babel-jest": "^26.6.2", "babel-plugin-module-resolver": "^3.2.0", "chalk": "^4.1.2", diff --git a/yarn.lock b/yarn.lock index d9e04afe6..5753abce1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2392,14 +2392,6 @@ resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c" integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA== -"@types/readable-stream@^2.3.0": - version "2.3.15" - resolved "https://registry.yarnpkg.com/@types/readable-stream/-/readable-stream-2.3.15.tgz#3d79c9ceb1b6a57d5f6e6976f489b9b5384321ae" - integrity sha512-oM5JSKQCcICF1wvGgmecmHldZ48OZamtMxcGGVICOJA8o8cahXC1zEVAif8iwoc5j8etxFaRFnf095+CDsuoFQ== - dependencies: - "@types/node" "*" - safe-buffer "~5.1.1" - "@types/semver@^6.0.2": version "6.2.1" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.1.tgz#a236185670a7860f1597cf73bea2e16d001461ba"