Skip to content

Commit

Permalink
fix(@jest/reporters): do not transform file paths into hyperlinks (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Oct 7, 2022
1 parent aeab64e commit 7e55a0c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 56 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@
### Fixes

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

Expand Down
1 change: 0 additions & 1 deletion packages/jest-reporters/package.json
Expand Up @@ -35,7 +35,6 @@
"slash": "^3.0.0",
"string-length": "^4.0.1",
"strip-ansi": "^6.0.0",
"terminal-link": "^2.0.0",
"v8-to-istanbul": "^9.0.1"
},
"devDependencies": {
Expand Down
23 changes: 0 additions & 23 deletions packages/jest-reporters/src/__tests__/getResultHeader.test.js
Expand Up @@ -7,9 +7,6 @@

import {makeGlobalConfig} from '@jest/test-utils';
import getResultHeader from '../getResultHeader';
const terminalLink = require('terminal-link');

jest.mock('terminal-link', () => jest.fn(() => 'wannabehyperlink'));

const endTime = 1577717671160;
const testTime = 5500;
Expand Down Expand Up @@ -38,26 +35,6 @@ const testResultFast = {

const globalConfig = makeGlobalConfig();

beforeEach(() => {
terminalLink.mockClear();
});

test('should call `terminal-link` correctly', () => {
getResultHeader(testResult, globalConfig);

expect(terminalLink).toHaveBeenCalledWith(
expect.stringContaining('foo'),
'file:///foo',
expect.objectContaining({fallback: expect.any(Function)}),
);
});

test('should render the terminal link', () => {
const result = getResultHeader(testResult, globalConfig);

expect(result).toContain('wannabehyperlink');
});

test('should display test time for slow test', () => {
const result = getResultHeader(testResultSlow, globalConfig);

Expand Down
15 changes: 4 additions & 11 deletions packages/jest-reporters/src/getResultHeader.ts
Expand Up @@ -6,7 +6,6 @@
*/

import chalk = require('chalk');
import terminalLink = require('terminal-link');
import type {TestResult} from '@jest/test-result';
import type {Config} from '@jest/types';
import {formatTime} from 'jest-util';
Expand All @@ -33,13 +32,6 @@ export default function getResultHeader(
projectConfig?: Config.ProjectConfig,
): string {
const testPath = result.testFilePath;
const formattedTestPath = formatTestPath(
projectConfig ? projectConfig : globalConfig,
testPath,
);
const fileLink = terminalLink(formattedTestPath, `file://${testPath}`, {
fallback: () => formattedTestPath,
});
const status =
result.numFailingTests > 0 || result.testExecError ? FAIL : PASS;

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

return `${status} ${projectDisplayName}${fileLink}${
testDetail.length ? ` (${testDetail.join(', ')})` : ''
}`;
return `${status} ${projectDisplayName}${formatTestPath(
projectConfig ?? globalConfig,
testPath,
)}${testDetail.length ? ` (${testDetail.join(', ')})` : ''}`;
}
21 changes: 0 additions & 21 deletions yarn.lock
Expand Up @@ -2874,7 +2874,6 @@ __metadata:
slash: ^3.0.0
string-length: ^4.0.1
strip-ansi: ^6.0.0
terminal-link: ^2.0.0
tsd-lite: ^0.6.0
v8-to-istanbul: ^9.0.1
peerDependencies:
Expand Down Expand Up @@ -19536,16 +19535,6 @@ __metadata:
languageName: node
linkType: hard

"supports-hyperlinks@npm:^2.0.0":
version: 2.2.0
resolution: "supports-hyperlinks@npm:2.2.0"
dependencies:
has-flag: ^4.0.0
supports-color: ^7.0.0
checksum: aef04fb41f4a67f1bc128f7c3e88a81b6cf2794c800fccf137006efe5bafde281da3e42e72bf9206c2fcf42e6438f37e3a820a389214d0a88613ca1f2d36076a
languageName: node
linkType: hard

"supports-preserve-symlinks-flag@npm:^1.0.0":
version: 1.0.0
resolution: "supports-preserve-symlinks-flag@npm:1.0.0"
Expand Down Expand Up @@ -19708,16 +19697,6 @@ __metadata:
languageName: node
linkType: hard

"terminal-link@npm:^2.0.0":
version: 2.1.1
resolution: "terminal-link@npm:2.1.1"
dependencies:
ansi-escapes: ^4.2.1
supports-hyperlinks: ^2.0.0
checksum: ce3d2cd3a438c4a9453947aa664581519173ea40e77e2534d08c088ee6dda449eabdbe0a76d2a516b8b73c33262fedd10d5270ccf7576ae316e3db170ce6562f
languageName: node
linkType: hard

"terser-webpack-plugin@npm:^5.1.3, terser-webpack-plugin@npm:^5.3.3":
version: 5.3.6
resolution: "terser-webpack-plugin@npm:5.3.6"
Expand Down

0 comments on commit 7e55a0c

Please sign in to comment.