@jest/reporters
Advanced tools
Comparing version 28.1.0 to 28.1.1
@@ -36,2 +36,3 @@ 'use strict'; | ||
} | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
@@ -45,2 +46,3 @@ onTestCaseResult(_test, _testCaseResult) {} | ||
onRunComplete(_testContexts, _aggregatedResults) {} | ||
/* eslint-enable */ | ||
@@ -47,0 +49,0 @@ _setError(error) { |
@@ -18,2 +18,12 @@ 'use strict'; | ||
function _jestMessageUtil() { | ||
const data = require('jest-message-util'); | ||
_jestMessageUtil = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _BaseReporter = _interopRequireDefault(require('./BaseReporter')); | ||
@@ -25,34 +35,93 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
const lineAndColumnInStackTrace = /^.*?:([0-9]+):([0-9]+).*$/; | ||
function _classPrivateMethodInitSpec(obj, privateSet) { | ||
_checkPrivateRedeclaration(obj, privateSet); | ||
privateSet.add(obj); | ||
} | ||
function replaceEntities(s) { | ||
// https://github.com/actions/toolkit/blob/b4639928698a6bfe1c4bdae4b2bfdad1cb75016d/packages/core/src/command.ts#L80-L85 | ||
const substitutions = [ | ||
[/%/g, '%25'], | ||
[/\r/g, '%0D'], | ||
[/\n/g, '%0A'] | ||
]; | ||
return substitutions.reduce((acc, sub) => acc.replace(...sub), s); | ||
function _checkPrivateRedeclaration(obj, privateCollection) { | ||
if (privateCollection.has(obj)) { | ||
throw new TypeError( | ||
'Cannot initialize the same private elements twice on an object' | ||
); | ||
} | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _classPrivateMethodGet(receiver, privateSet, fn) { | ||
if (!privateSet.has(receiver)) { | ||
throw new TypeError('attempted to get private field on non-instance'); | ||
} | ||
return fn; | ||
} | ||
const titleSeparator = ' \u203A '; | ||
var _getMessageDetails = /*#__PURE__*/ new WeakSet(); | ||
var _createAnnotation = /*#__PURE__*/ new WeakSet(); | ||
class GitHubActionsReporter extends _BaseReporter.default { | ||
static filename = __filename; | ||
constructor(...args) { | ||
super(...args); | ||
onRunComplete(_testContexts, aggregatedResults) { | ||
const messages = getMessages( | ||
aggregatedResults === null || aggregatedResults === void 0 | ||
? void 0 | ||
: aggregatedResults.testResults | ||
); | ||
_classPrivateMethodInitSpec(this, _createAnnotation); | ||
for (const message of messages) { | ||
this.log(message); | ||
} | ||
_classPrivateMethodInitSpec(this, _getMessageDetails); | ||
} | ||
onTestFileResult({context}, {testResults}) { | ||
testResults.forEach(result => { | ||
var _result$retryReasons; | ||
const title = [...result.ancestorTitles, result.title].join( | ||
titleSeparator | ||
); | ||
(_result$retryReasons = result.retryReasons) === null || | ||
_result$retryReasons === void 0 | ||
? void 0 | ||
: _result$retryReasons.forEach((retryReason, index) => { | ||
_classPrivateMethodGet( | ||
this, | ||
_createAnnotation, | ||
_createAnnotation2 | ||
).call(this, { | ||
..._classPrivateMethodGet( | ||
this, | ||
_getMessageDetails, | ||
_getMessageDetails2 | ||
).call(this, retryReason, context.config), | ||
title: `RETRY ${index + 1}: ${title}`, | ||
type: 'warning' | ||
}); | ||
}); | ||
result.failureMessages.forEach(failureMessage => { | ||
_classPrivateMethodGet( | ||
this, | ||
_createAnnotation, | ||
_createAnnotation2 | ||
).call(this, { | ||
..._classPrivateMethodGet( | ||
this, | ||
_getMessageDetails, | ||
_getMessageDetails2 | ||
).call(this, failureMessage, context.config), | ||
title, | ||
type: 'error' | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -62,17 +131,27 @@ | ||
function getMessages(results) { | ||
if (!results) return []; | ||
return results.flatMap(({testFilePath, testResults}) => | ||
testResults | ||
.filter(r => r.status === 'failed') | ||
.flatMap(r => r.failureMessages) | ||
.map(m => (0, _stripAnsi().default)(m)) | ||
.map(m => replaceEntities(m)) | ||
.map(m => lineAndColumnInStackTrace.exec(m)) | ||
.filter(m => m !== null) | ||
.map( | ||
([message, line, col]) => | ||
`\n::error file=${testFilePath},line=${line},col=${col}::${message}` | ||
) | ||
function _getMessageDetails2(failureMessage, config) { | ||
const {message, stack} = (0, _jestMessageUtil().separateMessageFromStack)( | ||
failureMessage | ||
); | ||
const stackLines = (0, _jestMessageUtil().getStackTraceLines)(stack); | ||
const topFrame = (0, _jestMessageUtil().getTopFrame)(stackLines); | ||
const normalizedStackLines = stackLines.map(line => | ||
(0, _jestMessageUtil().formatPath)(line, config) | ||
); | ||
const messageText = [message, ...normalizedStackLines].join('\n'); | ||
return { | ||
file: topFrame === null || topFrame === void 0 ? void 0 : topFrame.file, | ||
line: topFrame === null || topFrame === void 0 ? void 0 : topFrame.line, | ||
message: messageText | ||
}; | ||
} | ||
function _createAnnotation2({file, line, message, title, type}) { | ||
message = (0, _stripAnsi().default)( | ||
// copied from: https://github.com/actions/toolkit/blob/main/packages/core/src/command.ts | ||
message.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A') | ||
); | ||
this.log(`\n::${type} file=${file},line=${line},title=${title}::${message}`); | ||
} | ||
_defineProperty(GitHubActionsReporter, 'filename', __filename); |
@@ -135,7 +135,5 @@ /** | ||
export declare class GitHubActionsReporter extends BaseReporter { | ||
#private; | ||
static readonly filename: string; | ||
onRunComplete( | ||
_testContexts?: Set<TestContext>, | ||
aggregatedResults?: AggregatedResult, | ||
): void; | ||
onTestFileResult({context}: Test, {testResults}: TestResult): void; | ||
} | ||
@@ -142,0 +140,0 @@ |
{ | ||
"name": "@jest/reporters", | ||
"description": "Jest's reporters", | ||
"version": "28.1.0", | ||
"version": "28.1.1", | ||
"main": "./build/index.js", | ||
@@ -16,6 +16,6 @@ "types": "./build/index.d.ts", | ||
"@bcoe/v8-coverage": "^0.2.3", | ||
"@jest/console": "^28.1.0", | ||
"@jest/test-result": "^28.1.0", | ||
"@jest/transform": "^28.1.0", | ||
"@jest/types": "^28.1.0", | ||
"@jest/console": "^28.1.1", | ||
"@jest/test-result": "^28.1.1", | ||
"@jest/transform": "^28.1.1", | ||
"@jest/types": "^28.1.1", | ||
"@jridgewell/trace-mapping": "^0.3.7", | ||
@@ -33,4 +33,5 @@ "@types/node": "*", | ||
"istanbul-reports": "^3.1.3", | ||
"jest-util": "^28.1.0", | ||
"jest-worker": "^28.1.0", | ||
"jest-message-util": "^28.1.1", | ||
"jest-util": "^28.1.1", | ||
"jest-worker": "^28.1.1", | ||
"slash": "^3.0.0", | ||
@@ -43,4 +44,4 @@ "string-length": "^4.0.1", | ||
"devDependencies": { | ||
"@jest/test-utils": "^28.1.0", | ||
"@tsd/typescript": "~4.6.2", | ||
"@jest/test-utils": "^28.1.1", | ||
"@tsd/typescript": "~4.7.3", | ||
"@types/exit": "^0.1.30", | ||
@@ -55,3 +56,3 @@ "@types/glob": "^7.1.1", | ||
"@types/node-notifier": "^8.0.0", | ||
"jest-resolve": "^28.1.0", | ||
"jest-resolve": "^28.1.1", | ||
"mock-fs": "^5.1.2", | ||
@@ -84,3 +85,3 @@ "tsd-lite": "^0.5.1" | ||
}, | ||
"gitHead": "f5db241312f46528389e55c38221e6b6968622cf" | ||
"gitHead": "eb954f8874960920ac50a8f976bb333fbb06ada9" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108160
3272
26
+ Addedjest-message-util@^28.1.1
Updated@jest/console@^28.1.1
Updated@jest/test-result@^28.1.1
Updated@jest/transform@^28.1.1
Updated@jest/types@^28.1.1
Updatedjest-util@^28.1.1
Updatedjest-worker@^28.1.1