Skip to content

Commit 5debf7b

Browse files
committed
feat(scripts/jest): configure Jest with GitHub actions reporter when on actions
1 parent 034566f commit 5debf7b

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/scripts/__tests__/__snapshots__/test.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
exports[`test calls jest.run with default args 1`] = `--config {"builtInConfig":true} --watch`;
44

5+
exports[`test configures GitHub actions reporter on GitHub actions 1`] = `--config {"builtInConfig":true} --reporters=default --reporters=jest-github-actions-reporter`;
6+
57
exports[`test does not watch --updateSnapshot 1`] = `--config {"builtInConfig":true} --updateSnapshot`;
68

79
exports[`test does not watch on CI 1`] = `--config {"builtInConfig":true}`;

src/scripts/__tests__/test.js

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ cases(
6969
'does not watch on SCRIPTS_PRE-COMMIT': {
7070
env: {'SCRIPTS_PRE-COMMIT': true},
7171
},
72+
'configures GitHub actions reporter on GitHub actions': {
73+
ci: true,
74+
env: {GITHUB_WORKFLOW: 'test.yml'},
75+
},
7276
'does not watch with --no-watch': {
7377
args: ['--no-watch'],
7478
},

src/scripts/test.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@ const config =
2222
? ['--config', JSON.stringify(require('../config/jest.config'))]
2323
: []
2424

25+
const reporters =
26+
isCI && process.env.GITHUB_WORKFLOW
27+
? ['--reporters=default', '--reporters=jest-github-actions-reporter']
28+
: []
29+
2530
// eslint-disable-next-line jest/no-jest-import
26-
require('jest').run([...config, ...watch, ...args])
31+
require('jest').run([...config, ...watch, ...reporters, ...args])

0 commit comments

Comments
 (0)