Skip to content

Commit 7e55a0c

Browse files
authored
fix(@jest/reporters): do not transform file paths into hyperlinks (#13399)
1 parent aeab64e commit 7e55a0c

File tree

5 files changed

+5
-56
lines changed

5 files changed

+5
-56
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Fixes
1010

1111
- `[babel-plugin-jest-hoist]` Ignore `TSTypeQuery` when checking for hoisted references ([#13367](https://github.com/facebook/jest/pull/13367))
12+
- `[jest-reporters]` Revert: Transform file paths into hyperlinks ([#13399](https://github.com/facebook/jest/pull/13399))
1213
- `[@jest/types]` Infer type of `each` table correctly when the table is a tuple or array ([#13381](https://github.com/facebook/jest/pull/13381))
1314
- `[@jest/types]` Rework typings to allow the `*ReturnedWith` matchers to be called with no argument ([#13385](https://github.com/facebook/jest/pull/13385))
1415

packages/jest-reporters/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"slash": "^3.0.0",
3636
"string-length": "^4.0.1",
3737
"strip-ansi": "^6.0.0",
38-
"terminal-link": "^2.0.0",
3938
"v8-to-istanbul": "^9.0.1"
4039
},
4140
"devDependencies": {

packages/jest-reporters/src/__tests__/getResultHeader.test.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
import {makeGlobalConfig} from '@jest/test-utils';
99
import getResultHeader from '../getResultHeader';
10-
const terminalLink = require('terminal-link');
11-
12-
jest.mock('terminal-link', () => jest.fn(() => 'wannabehyperlink'));
1310

1411
const endTime = 1577717671160;
1512
const testTime = 5500;
@@ -38,26 +35,6 @@ const testResultFast = {
3835

3936
const globalConfig = makeGlobalConfig();
4037

41-
beforeEach(() => {
42-
terminalLink.mockClear();
43-
});
44-
45-
test('should call `terminal-link` correctly', () => {
46-
getResultHeader(testResult, globalConfig);
47-
48-
expect(terminalLink).toHaveBeenCalledWith(
49-
expect.stringContaining('foo'),
50-
'file:///foo',
51-
expect.objectContaining({fallback: expect.any(Function)}),
52-
);
53-
});
54-
55-
test('should render the terminal link', () => {
56-
const result = getResultHeader(testResult, globalConfig);
57-
58-
expect(result).toContain('wannabehyperlink');
59-
});
60-
6138
test('should display test time for slow test', () => {
6239
const result = getResultHeader(testResultSlow, globalConfig);
6340

packages/jest-reporters/src/getResultHeader.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import chalk = require('chalk');
9-
import terminalLink = require('terminal-link');
109
import type {TestResult} from '@jest/test-result';
1110
import type {Config} from '@jest/types';
1211
import {formatTime} from 'jest-util';
@@ -33,13 +32,6 @@ export default function getResultHeader(
3332
projectConfig?: Config.ProjectConfig,
3433
): string {
3534
const testPath = result.testFilePath;
36-
const formattedTestPath = formatTestPath(
37-
projectConfig ? projectConfig : globalConfig,
38-
testPath,
39-
);
40-
const fileLink = terminalLink(formattedTestPath, `file://${testPath}`, {
41-
fallback: () => formattedTestPath,
42-
});
4335
const status =
4436
result.numFailingTests > 0 || result.testExecError ? FAIL : PASS;
4537

@@ -61,7 +53,8 @@ export default function getResultHeader(
6153
? `${printDisplayName(projectConfig)} `
6254
: '';
6355

64-
return `${status} ${projectDisplayName}${fileLink}${
65-
testDetail.length ? ` (${testDetail.join(', ')})` : ''
66-
}`;
56+
return `${status} ${projectDisplayName}${formatTestPath(
57+
projectConfig ?? globalConfig,
58+
testPath,
59+
)}${testDetail.length ? ` (${testDetail.join(', ')})` : ''}`;
6760
}

yarn.lock

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,7 +2874,6 @@ __metadata:
28742874
slash: ^3.0.0
28752875
string-length: ^4.0.1
28762876
strip-ansi: ^6.0.0
2877-
terminal-link: ^2.0.0
28782877
tsd-lite: ^0.6.0
28792878
v8-to-istanbul: ^9.0.1
28802879
peerDependencies:
@@ -19536,16 +19535,6 @@ __metadata:
1953619535
languageName: node
1953719536
linkType: hard
1953819537

19539-
"supports-hyperlinks@npm:^2.0.0":
19540-
version: 2.2.0
19541-
resolution: "supports-hyperlinks@npm:2.2.0"
19542-
dependencies:
19543-
has-flag: ^4.0.0
19544-
supports-color: ^7.0.0
19545-
checksum: aef04fb41f4a67f1bc128f7c3e88a81b6cf2794c800fccf137006efe5bafde281da3e42e72bf9206c2fcf42e6438f37e3a820a389214d0a88613ca1f2d36076a
19546-
languageName: node
19547-
linkType: hard
19548-
1954919538
"supports-preserve-symlinks-flag@npm:^1.0.0":
1955019539
version: 1.0.0
1955119540
resolution: "supports-preserve-symlinks-flag@npm:1.0.0"
@@ -19708,16 +19697,6 @@ __metadata:
1970819697
languageName: node
1970919698
linkType: hard
1971019699

19711-
"terminal-link@npm:^2.0.0":
19712-
version: 2.1.1
19713-
resolution: "terminal-link@npm:2.1.1"
19714-
dependencies:
19715-
ansi-escapes: ^4.2.1
19716-
supports-hyperlinks: ^2.0.0
19717-
checksum: ce3d2cd3a438c4a9453947aa664581519173ea40e77e2534d08c088ee6dda449eabdbe0a76d2a516b8b73c33262fedd10d5270ccf7576ae316e3db170ce6562f
19718-
languageName: node
19719-
linkType: hard
19720-
1972119700
"terser-webpack-plugin@npm:^5.1.3, terser-webpack-plugin@npm:^5.3.3":
1972219701
version: 5.3.6
1972319702
resolution: "terser-webpack-plugin@npm:5.3.6"

0 commit comments

Comments
 (0)