-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat(jest-core): GitHubActionsReporter goes live
#12658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
68d56c5
feat: GitHubActions goes live
mrazauskas b1ce7f4
wrong config?
mrazauskas 8ac8ce0
line break?
mrazauskas 12c4de7
snap
mrazauskas 6fdfc0d
fix test
mrazauskas a6a96fb
changelog entry
mrazauskas 42467d1
use ci-info
mrazauskas fe6c908
ups..
mrazauskas f842845
inline reporter names
mrazauskas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import exit = require('exit'); | |
| import { | ||
| CoverageReporter, | ||
| DefaultReporter, | ||
| GitHubActionsReporter, | ||
| NotifyReporter, | ||
| Reporter, | ||
| SummaryReporter, | ||
|
|
@@ -28,6 +29,7 @@ import { | |
| } from '@jest/test-result'; | ||
| import {createScriptTransformer} from '@jest/transform'; | ||
| import type {Config} from '@jest/types'; | ||
| import {constants} from 'jest-config'; | ||
| import {formatExecError} from 'jest-message-util'; | ||
| import type {JestTestRunner, TestRunnerContext} from 'jest-runner'; | ||
| import type {Context} from 'jest-runtime'; | ||
|
|
@@ -330,25 +332,40 @@ class TestScheduler { | |
| } | ||
| } | ||
|
|
||
| private _shouldAddDefaultReporters( | ||
| reporters?: Array<string | Config.ReporterConfig>, | ||
| ): boolean { | ||
| return ( | ||
| !reporters || | ||
| !!reporters.find( | ||
| reporter => this._getReporterProps(reporter).path === 'default', | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| async _setupReporters() { | ||
| const {collectCoverage, notify, reporters} = this._globalConfig; | ||
| const isDefault = this._shouldAddDefaultReporters(reporters); | ||
|
|
||
| if (notify) { | ||
| this.addReporter( | ||
| new NotifyReporter( | ||
| this._globalConfig, | ||
| this._options.startRun, | ||
| this._context, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| if (!reporters) { | ||
| this._setupDefaultReporters(collectCoverage); | ||
| return; | ||
| } | ||
|
Comment on lines
+348
to
+351
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding |
||
|
|
||
| const reporterNames = reporters.map( | ||
| reporter => this._getReporterProps(reporter).path, | ||
| ); | ||
|
|
||
| const isDefault = reporterNames?.includes('default'); | ||
| const isGitHubActions = | ||
| process.env.GITHUB_ACTIONS && reporterNames?.includes('github-actions'); | ||
|
|
||
| if (isDefault) { | ||
| this._setupDefaultReporters(collectCoverage); | ||
| } | ||
|
|
||
| if (isGitHubActions) { | ||
| this.addReporter(new GitHubActionsReporter()); | ||
| } | ||
|
|
||
| if (!isDefault && collectCoverage) { | ||
| this.addReporter( | ||
| new CoverageReporter(this._globalConfig, { | ||
|
|
@@ -359,19 +376,7 @@ class TestScheduler { | |
| ); | ||
| } | ||
|
|
||
| if (notify) { | ||
| this.addReporter( | ||
| new NotifyReporter( | ||
| this._globalConfig, | ||
| this._options.startRun, | ||
| this._context, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| if (reporters && Array.isArray(reporters)) { | ||
| await this._addCustomReporters(reporters); | ||
| } | ||
| await this._addCustomReporters(reporters); | ||
| } | ||
|
|
||
| private _setupDefaultReporters(collectCoverage: boolean) { | ||
|
|
@@ -400,7 +405,7 @@ class TestScheduler { | |
| for (const reporter of reporters) { | ||
| const {options, path} = this._getReporterProps(reporter); | ||
|
|
||
| if (path === 'default') continue; | ||
| if (constants.BUILD_IN_REPORTERS.includes(path)) continue; | ||
|
|
||
| try { | ||
| const Reporter = await requireOrImportModule<any>(path, true); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/jest-reporters/src/__tests__/__snapshots__/GitHubActionsReporter.test.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`reporter extracts the correct filename, line, and column 1`] = ` | ||
| "::error file=/home/runner/work/jest/jest/some.test.js,line=4,col=17::%0A Error: expect(received).toBe(expected) // Object.is equality%0A%0A %0A%0A Expected: "b"%0A%0A Received: "a"%0A%0A at Object.<anonymous> (/home/runner/work/jest/jest/some.test.js:4:17)%0A%0A at Object.asyncJestTest (/home/runner/work/jest/jest/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)%0A%0A at /home/runner/work/jest/jest/node_modules/jest-jasmine2/build/queueRunner.js:45:12%0A%0A at new Promise (<anonymous>)%0A%0A at mapper (/home/runner/work/jest/jest/node_modules/jest-jasmine2/build/queueRunner.js:28:19)%0A%0A at /home/runner/work/jest/jest/node_modules/jest-jasmine2/build/queueRunner.js:75:41%0A%0A at processTicksAndRejections (internal/process/task_queues.js:93:5)%0A | ||
| " | ||
| ::error file=/home/runner/work/jest/jest/some.test.js,line=4,col=17::%0A Error: expect(received).toBe(expected) // Object.is equality%0A%0A %0A%0A Expected: "b"%0A%0A Received: "a"%0A%0A at Object.<anonymous> (/home/runner/work/jest/jest/some.test.js:4:17)%0A%0A at Object.asyncJestTest (/home/runner/work/jest/jest/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)%0A%0A at /home/runner/work/jest/jest/node_modules/jest-jasmine2/build/queueRunner.js:45:12%0A%0A at new Promise (<anonymous>)%0A%0A at mapper (/home/runner/work/jest/jest/node_modules/jest-jasmine2/build/queueRunner.js:28:19)%0A%0A at /home/runner/work/jest/jest/node_modules/jest-jasmine2/build/queueRunner.js:75:41%0A%0A at processTicksAndRejections (internal/process/task_queues.js:93:5)%0A | ||
| " | ||
| `; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.