Skip to content
Merged
Show file tree
Hide file tree
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
Next Next commit
use code frame
  • Loading branch information
SimenB committed May 6, 2018
commit bf5e5878167e12cf21dc48460af4bb5b40514496
2 changes: 0 additions & 2 deletions packages/jest-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
41 changes: 14 additions & 27 deletions packages/jest-cli/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ 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';
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';
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 2 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
dependencies:
"@babel/highlight" "7.0.0-beta.46"

"@babel/[email protected]", "@babel/highlight@^7.0.0-beta.46":
"@babel/[email protected]":
version "7.0.0-beta.46"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.46.tgz#c553c51e65f572bdedd6eff66fc0bb563016645e"
dependencies:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -9632,7 +9624,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:
Expand Down