diff --git a/tests/e2e/utils/execAsync.js b/tests/e2e/utils/execAsync.ts similarity index 72% rename from tests/e2e/utils/execAsync.js rename to tests/e2e/utils/execAsync.ts index b7dd93d8963e..8f1a4ec10c6b 100644 --- a/tests/e2e/utils/execAsync.js +++ b/tests/e2e/utils/execAsync.ts @@ -1,17 +1,19 @@ import {exec} from 'child_process'; +import type {ChildProcess} from 'child_process'; import * as Logger from './logger'; +type PromiseWithAbort = Promise & { + abort?: () => void; +}; + /** * Executes a command none-blocking by wrapping it in a promise. * In addition to the promise it returns an abort function. - * @param {string} command - * @param {object} env environment variables - * @returns {Promise} */ -export default (command, env = {}) => { - let childProcess; - const promise = new Promise((resolve, reject) => { - const finalEnv = { +export default (command: string, env: NodeJS.ProcessEnv = {}): PromiseWithAbort => { + let childProcess: ChildProcess; + const promise: PromiseWithAbort = new Promise((resolve, reject) => { + const finalEnv: NodeJS.ProcessEnv = { ...process.env, ...env, }; @@ -29,7 +31,7 @@ export default (command, env = {}) => { if (error && error.killed) { resolve(); } else { - Logger.error(`failed with error: ${error}`); + Logger.error(`failed with error: ${error.message}`); reject(error); } } else { diff --git a/tests/e2e/utils/logger.js b/tests/e2e/utils/logger.js index d0770b7aa8e4..6a39b4c10328 100644 --- a/tests/e2e/utils/logger.js +++ b/tests/e2e/utils/logger.js @@ -66,12 +66,4 @@ const error = (...args) => { log(...lines); }; -module.exports = { - log, - info, - warn, - note, - error, - success, - writeToLogFile, -}; +export {log, info, warn, note, error, success, writeToLogFile};