New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mocha-github-actions-reporter

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha-github-actions-reporter - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

54

lib/index.js

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc