Skip to content

Commit

Permalink
Fix error message for sl (steam locomotive)
Browse files Browse the repository at this point in the history
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: jestjs#14046
  • Loading branch information
rmartine-ias committed May 3, 2024
1 parent 654dbd6 commit 7edc18d
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions packages/jest-changed-files/src/sl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import * as path from 'path';
import {types} from 'util';
import execa = require('execa');
import type {SCMAdapter} from './types';

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

let result: execa.ExecaReturnValue;

try {
result = await execa('sl', args, {cwd, env});
} catch (error) {
if (types.isNativeError(error)) {
const err = error as execa.ExecaError;
// TODO: Should we keep the original `message`?
err.message = err.stderr;
}

throw error;
}
const result = await execa('sl', args, {cwd, env});

return result.stdout
.split('\n')
Expand Down

0 comments on commit 7edc18d

Please sign in to comment.