-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from l-peacock/feature/prValidation2
Tests: Fixed syntax error in workflow yaml
- Loading branch information
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* A custom reporter for jest test results. | ||
* This will convert jest test coverage output into the expected format for github actions. | ||
* Referenced for https://joelhooks.com/jest-and-github-actions/ | ||
*/ | ||
class GithubActionsReporter { | ||
constructor(globalConfig, options) { | ||
this._globalConfig = globalConfig; | ||
this._options = options; | ||
} | ||
|
||
onRunComplete(contexts, results) { | ||
results.testResults.forEach((testResultItem) => { | ||
const testFilePath = testResultItem.testFilePath; | ||
|
||
testResultItem.testResults.forEach((result) => { | ||
if (result.status !== "failed") { | ||
return; | ||
} | ||
|
||
result.failureMessages.forEach((failureMessages) => { | ||
const newLine = "%0A"; | ||
const message = failureMessages.replace(/\n/g, newLine); | ||
const captureGroup = message.match(/:([0-9]+):([0-9]+)/); | ||
|
||
if (!captureGroup) { | ||
console.log("Unable to extract line number from call stack"); | ||
return; | ||
} | ||
|
||
const [, line, col] = captureGroup; | ||
console.log( | ||
`::error file=${testFilePath},line=${line},col=${col}::${message}`, | ||
); | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export default GithubActionsReporter; |
This file contains 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