diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index 4cf9f9d30e9e..5b61b31091cf 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -4,10 +4,8 @@ "version": "22.4.2", "main": "build/jest.js", "dependencies": { - "@babel/highlight": "^7.0.0-beta.46", "ansi-escapes": "^3.0.0", "chalk": "^2.0.1", - "easy-table": "^1.1.1", "exit": "^0.1.2", "glob": "^7.1.2", "graceful-fs": "^4.1.11", diff --git a/packages/jest-cli/src/cli/index.js b/packages/jest-cli/src/cli/index.js index da11c4aa9203..6b5294961dc5 100644 --- a/packages/jest-cli/src/cli/index.js +++ b/packages/jest-cli/src/cli/index.js @@ -14,6 +14,7 @@ import type {GlobalConfig, Path, ProjectConfig} from 'types/Config'; import {Console, clearLine, createDirectory} from 'jest-util'; import {validateCLIOptions} from 'jest-validate'; import {readConfig, deprecationEntries} from 'jest-config'; +import {formatStackTrace} from 'jest-message-util'; import {version as VERSION} from '../../package.json'; import * as args from './args'; import chalk from 'chalk'; @@ -21,7 +22,6 @@ import createContext from '../lib/create_context'; import exit from 'exit'; import getChangedFilesPromise from '../get_changed_files_promise'; import fs from 'fs'; -import path from 'path'; import handleDeprecationWarnings from '../lib/handle_deprecation_warnings'; import logDebugMessages from '../lib/log_debug_messages'; import {print as preRunMessagePrint} from '../pre_run_message'; @@ -33,9 +33,6 @@ import pluralize from '../pluralize'; import yargs from 'yargs'; import rimraf from 'rimraf'; import {sync as realpath} from 'realpath-native'; -import Table from 'easy-table'; -import slash from 'slash'; -import highlight from '@babel/highlight'; export async function run(maybeArgv?: Argv, project?: Path) { try { @@ -110,35 +107,25 @@ export const runCLI = async ( if (openHandles && openHandles.length) { const handles = openHandles - .map(({title, entries}) => { - const table = new Table(); - - entries - .map(({file, line}) => { - const relativeTestPath = slash( - path.relative(globalConfig.rootDir, file), - ); - const highlightedLine = highlight(line); - - return {file: relativeTestPath, line: highlightedLine}; - }) - .forEach(({file, line}) => { - table.cell('File', file); - table.cell('Line', line); - table.newRow(); - }); - - return title + '\n' + table.toString(); - }) + .map(({title, entries}) => ({ + // Fake column to make it a valid stack trace + stack: entries.map(({file}) => `at ${file}:0`).join('\n'), + title, + })) + .map( + ({title, stack}) => + title + + '\n' + + // First config should be fine + formatStackTrace(stack, configs[0], {noStackTrace: false}), + ) .join('\n\n'); const openHandlesString = pluralize('open handle', openHandles.length, 's'); const message = chalk.red( - '\nJest has detected the following ' + - `${openHandlesString} potentially keeping Jest from ` + - 'exiting:\n\n', + `\nJest has detected the following ${openHandlesString} potentially keeping Jest from exiting:\n\n`, ) + handles; console.error(message); diff --git a/yarn.lock b/yarn.lock index 0468b1e024ae..ae90611dc304 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8,7 +8,7 @@ dependencies: "@babel/highlight" "7.0.0-beta.46" -"@babel/highlight@7.0.0-beta.46", "@babel/highlight@^7.0.0-beta.46": +"@babel/highlight@7.0.0-beta.46": version "7.0.0-beta.46" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.46.tgz#c553c51e65f572bdedd6eff66fc0bb563016645e" dependencies: @@ -3030,14 +3030,6 @@ duplexer@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" -easy-table@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/easy-table/-/easy-table-1.1.1.tgz#c1b9b9ad68a017091a1c235e4bcba277540e143f" - dependencies: - ansi-regex "^3.0.0" - optionalDependencies: - wcwidth ">=1.0.1" - ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" @@ -9620,7 +9612,7 @@ watchify@^3.9.0: through2 "^2.0.0" xtend "^4.0.0" -wcwidth@>=1.0.1, wcwidth@^1.0.0: +wcwidth@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" dependencies: