mocha-github-actions-reporter
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,40 +0,36 @@ | ||
const { issueCommand, issue } = require("@actions/core/lib/command"); | ||
const mocha = require("mocha"); | ||
const { extractModuleLineAndColumn } = require("./parse-stack-trace"); | ||
const core = require('@actions/core'); | ||
const { issueCommand } = require('@actions/core/lib/command'); | ||
const mocha = require('mocha'); | ||
const { extractModuleLineAndColumn } = require('./parse-stack-trace'); | ||
const { Spec } = mocha.reporters; | ||
const { inherits } = mocha.utils; | ||
const { EVENT_TEST_FAIL, EVENT_RUN_END } = mocha.Runner.constants; | ||
function GithubActionsReporter(runner, options) { | ||
Spec.call(this, runner, options); | ||
Spec.call(this, runner, options); | ||
const failures = []; | ||
const failures = []; | ||
runner.on(EVENT_TEST_FAIL, function(test) { | ||
failures.push(test); | ||
}); | ||
runner.on(EVENT_TEST_FAIL, function(test) { | ||
failures.push(test); | ||
}); | ||
runner.once(EVENT_RUN_END, function() { | ||
issue("group", "Mocha Annotations"); | ||
runner.once(EVENT_RUN_END, function() { | ||
if (failures.length > 0) { | ||
core.startGroup('Mocha Annotations'); | ||
if (failures.length > 0) { | ||
for (const test of failures) { | ||
const errMessage = test.err.message; | ||
const moduleLineColumn = extractModuleLineAndColumn(err.stack); | ||
for (const test of failures) { | ||
const errMessage = test.err.message; | ||
const moduleLineColumn = extractModuleLineAndColumn(test.err.stack); | ||
issueCommand( | ||
"error", | ||
{ | ||
file: moduleLineColumn.file, | ||
line: moduleLineColumn.line, | ||
col: moduleLineColumn.column | ||
}, | ||
errMessage | ||
); | ||
} | ||
} | ||
issueCommand('error', { | ||
file: moduleLineColumn.file, | ||
line: moduleLineColumn.line + '', | ||
col: moduleLineColumn.column + '' | ||
}, errMessage); | ||
} | ||
issue("endgroup"); | ||
}); | ||
core.endGroup(); | ||
} | ||
}); | ||
} | ||
@@ -45,4 +41,4 @@ | ||
*/ | ||
inherits(GithubActionsReporter, Spec); | ||
mocha.utils.inherits(GithubActionsReporter, Spec); | ||
module.exports = GithubActionsReporter; |
// From https://github.com/findmypast-oss/mocha-json-streamier-reporter/blob/master/lib/parse-stack-trace.js | ||
function extractModuleLineAndColumn(stackTrace) { | ||
var matches = /^\s*at Context.* \(([^\(\)]+):([0-9]+):([0-9]+)\)/gm.exec( | ||
stackTrace | ||
); | ||
let matches = /^\s*at Context.* \(([^\(\)]+):([0-9]+):([0-9]+)\)/gm.exec(stackTrace); | ||
if (matches === null) { | ||
return {}; | ||
} | ||
if (matches === null) { | ||
return {}; | ||
} | ||
return { | ||
file: matches[1], | ||
line: parseIntOrUndefined(matches[2]), | ||
column: parseIntOrUndefined(matches[3]) | ||
}; | ||
return { | ||
file: matches[1], | ||
line: parseIntOrUndefined(matches[2]), | ||
column: parseIntOrUndefined(matches[3]) | ||
}; | ||
} | ||
function parseIntOrUndefined(numberString) { | ||
const lineNumber = parseInt(numberString); | ||
const lineNumber = parseInt(numberString); | ||
if (isNaN(lineNumber)) { | ||
return undefined; | ||
} | ||
if (isNaN(lineNumber)) { | ||
return undefined; | ||
} | ||
return lineNumber; | ||
return lineNumber; | ||
} | ||
module.exports = { extractModuleLineAndColumn }; |
{ | ||
"name": "mocha-github-actions-reporter", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Report for mocha that outputs Github Actions annotations", | ||
"main": "index.js", | ||
"repository": "https://github.com/albertfdp/mocha-github-actions-reporter", | ||
"author": "Daniel Lockyer", | ||
"repository": "https://github.com/daniellockyer/mocha-github-actions-reporter", | ||
"bugs": { | ||
"url": "https://github.com/daniellockyer/mocha-github-actions-reporter/issues" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"ship": "STATUS=$(git status --porcelain); echo $STATUS; if [ -z \"$STATUS\" ]; then yarn publish && git push --follow-tags; fi" | ||
}, | ||
"dependencies": { | ||
"@actions/core": "^1.2.2" | ||
"@actions/core": "1.2.3" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^7.0.0" | ||
"mocha": "7.1.1" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
3973
0
60
1
+ Added@actions/core@1.2.3(transitive)
- Removed@actions/core@1.11.1(transitive)
- Removed@actions/exec@1.1.1(transitive)
- Removed@actions/http-client@2.2.3(transitive)
- Removed@actions/io@1.1.3(transitive)
- Removed@fastify/busboy@2.1.1(transitive)
- Removedtunnel@0.0.6(transitive)
- Removedundici@5.28.5(transitive)
Updated@actions/core@1.2.3