Skip to content

Commit 85bab0e

Browse files
authored
Fix error message for sl (steam locomotive) (#15052)
* Fix error message for `sl` (steam locomotive) When running jest in watch mode, with `sl` installed (https://github.com/mtoyoda/sl), it errors out with the following message: ``` ● Test suite failed to run thrown: [Error] ``` This is bad because the error is extremely hard to debug. This change makes it error as follows: ``` ● Test suite failed to run Command failed with ENAMETOOLONG: sl status -amnu /Users/rmartine/dev/ias-backstage/packages/backend spawn ENAMETOOLONG ``` This, at least, points people in the right direction. See also: #14046
1 parent 654dbd6 commit 85bab0e

File tree

4 files changed

+4
-42
lines changed

4 files changed

+4
-42
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
- `[babel-plugin-jest-hoist]` Use `denylist` instead of the deprecated `blacklist` for Babel 8 support ([#14109](https://github.com/jestjs/jest/pull/14109))
4141
- `[expect]` Check error instance type for `toThrow/toThrowError` ([#14576](https://github.com/jestjs/jest/pull/14576))
42+
- `[jest-changed-files]` Print underlying errors when VCS commands fail ([#15052](https://github.com/jestjs/jest/pull/15052))
4243
- `[jest-circus]` [**BREAKING**] Prevent false test failures caused by promise rejections handled asynchronously ([#14315](https://github.com/jestjs/jest/pull/14315))
4344
- `[jest-circus]` Replace recursive `makeTestResults` implementation with iterative one ([#14760](https://github.com/jestjs/jest/pull/14760))
4445
- `[jest-circus]` Omit `expect.hasAssertions()` errors if a test already has errors ([#14866](https://github.com/jestjs/jest/pull/14866))

packages/jest-changed-files/src/git.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,14 @@
77
*/
88

99
import * as path from 'path';
10-
import {types} from 'util';
1110
import execa = require('execa');
1211
import type {SCMAdapter} from './types';
1312

1413
const findChangedFilesUsingCommand = async (
1514
args: Array<string>,
1615
cwd: string,
1716
): Promise<Array<string>> => {
18-
let result: execa.ExecaReturnValue;
19-
20-
try {
21-
result = await execa('git', args, {cwd});
22-
} catch (error) {
23-
if (types.isNativeError(error)) {
24-
const err = error as execa.ExecaError;
25-
// TODO: Should we keep the original `message`?
26-
err.message = err.stderr;
27-
}
28-
29-
throw error;
30-
}
17+
const result = await execa('git', args, {cwd});
3118

3219
return result.stdout
3320
.split('\n')

packages/jest-changed-files/src/hg.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import * as path from 'path';
10-
import {types} from 'util';
1110
import execa = require('execa');
1211
import type {SCMAdapter} from './types';
1312

@@ -30,19 +29,7 @@ const adapter: SCMAdapter = {
3029
}
3130
args.push(...includePaths);
3231

33-
let result: execa.ExecaReturnValue;
34-
35-
try {
36-
result = await execa('hg', args, {cwd, env});
37-
} catch (error) {
38-
if (types.isNativeError(error)) {
39-
const err = error as execa.ExecaError;
40-
// TODO: Should we keep the original `message`?
41-
err.message = err.stderr;
42-
}
43-
44-
throw error;
45-
}
32+
const result = await execa('hg', args, {cwd, env});
4633

4734
return result.stdout
4835
.split('\n')

packages/jest-changed-files/src/sl.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import * as path from 'path';
10-
import {types} from 'util';
1110
import execa = require('execa');
1211
import type {SCMAdapter} from './types';
1312

@@ -34,19 +33,7 @@ const adapter: SCMAdapter = {
3433
}
3534
args.push(...includePaths);
3635

37-
let result: execa.ExecaReturnValue;
38-
39-
try {
40-
result = await execa('sl', args, {cwd, env});
41-
} catch (error) {
42-
if (types.isNativeError(error)) {
43-
const err = error as execa.ExecaError;
44-
// TODO: Should we keep the original `message`?
45-
err.message = err.stderr;
46-
}
47-
48-
throw error;
49-
}
36+
const result = await execa('sl', args, {cwd, env});
5037

5138
return result.stdout
5239
.split('\n')

0 commit comments

Comments
 (0)