Skip to content

Commit fc6dd30

Browse files
committed
Use ci-info to check for GHA
1 parent 97a7b1c commit fc6dd30

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

packages/jest-reporters/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@jest/types": "^28.0.0-alpha.5",
2020
"@types/node": "*",
2121
"chalk": "^4.0.0",
22+
"ci-info": "^3.2.0",
2223
"collect-v8-coverage": "^1.0.0",
2324
"exit": "^0.1.2",
2425
"glob": "^7.1.2",

packages/jest-reporters/src/GithubActionsReporter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import {GITHUB_ACTIONS} from 'ci-info';
89
import type {AggregatedResult, TestResult} from '@jest/test-result';
910
import BaseReporter from './BaseReporter';
1011
import type {Context} from './types';
@@ -18,7 +19,7 @@ export default class GithubActionsReporter extends BaseReporter {
1819
_contexts?: Set<Context>,
1920
aggregatedResults?: AggregatedResult,
2021
): void {
21-
if (!process.env.GITHUB_ACTIONS) {
22+
if (!GITHUB_ACTIONS) {
2223
return;
2324
}
2425

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
let GithubActionsReporter;
1010

11-
const env = {...process.env};
1211
const write = process.stderr.write;
1312
const globalConfig = {
1413
rootDir: 'root',
@@ -29,7 +28,6 @@ beforeEach(() => {
2928

3029
afterEach(() => {
3130
results = [];
32-
process.env = env;
3331
process.stderr.write = write;
3432
});
3533

@@ -120,7 +118,7 @@ test("reporter returns empty string if GITHUB_ACTIONS isn't set", () => {
120118
});
121119

122120
test('reporter extracts the correct filename, line, and column', () => {
123-
process.env.GITHUB_ACTIONS = true;
121+
jest.doMock('ci-info', () => ({GITHUB_ACTIONS: true}));
124122

125123
requireReporter();
126124
const testReporter = new GithubActionsReporter(globalConfig);

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,6 +2743,7 @@ __metadata:
27432743
"@types/node": "*"
27442744
"@types/node-notifier": ^8.0.0
27452745
chalk: ^4.0.0
2746+
ci-info: ^3.2.0
27462747
collect-v8-coverage: ^1.0.0
27472748
exit: ^0.1.2
27482749
glob: ^7.1.2

0 commit comments

Comments
 (0)