Socket
Socket
Sign inDemoInstall

@skills17/karma-helpers

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skills17/karma-helpers - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

67

lib/reporter.js
"use strict";
var _path = _interopRequireDefault(require("path"));
var _fs = _interopRequireDefault(require("fs"));
var _util = _interopRequireDefault(require("util"));

@@ -7,2 +11,4 @@

var _uniqid = _interopRequireDefault(require("uniqid"));
var _taskConfig = _interopRequireDefault(require("@skills17/task-config"));

@@ -40,2 +46,3 @@

* Print test failures with specific error messages
*
* @param results Test results

@@ -58,3 +65,3 @@ */

result.log.forEach(log => {
console.error(` ${_chalk.default.red(formatError(log).split('\n').join('\n '))}`);
console.error(` ${_chalk.default.red(formatError(log).trim().split('\n').join('\n '))}\n`);
});

@@ -65,2 +72,26 @@ }

/**
* Stores a test run in the local history
*
* @param config Task config
* @param testRun Test run
*/
const storeTestRun = (config, testRun) => {
const historyDir = _path.default.resolve(config.getProjectRoot(), '.history');
const historyFile = _path.default.resolve(historyDir, `${(0, _uniqid.default)()}.json`); // create history dir if it doesn't exist
if (!_fs.default.existsSync(historyDir)) {
_fs.default.mkdirSync(historyDir);
} // write history file
_fs.default.writeFileSync(historyFile, JSON.stringify({
time: Math.round(new Date().getTime() / 1000),
...testRun.toJSON()
}, undefined, 2));
};
/**
* Create a new reporter

@@ -74,11 +105,10 @@ *

const reporter = function Skills17Reporter(logger, formatError) {
const task = new _taskConfig.default();
task.loadFromFileSync();
const config = new _taskConfig.default();
config.loadFromFileSync();
const testRun = {};
const errors = {};
const testFailures = {};
const logs = {}; // create a new test run for each browser
const testFailures = {}; // create a new test run for each browser
this.onBrowserStart = function onBrowserStart(browser) {
testRun[browser.id] = task.createTestRun();
testRun[browser.id] = config.createTestRun();
}; // save single test result

@@ -88,3 +118,3 @@

this.onSpecComplete = function onSpecComplete(browser, result) {
testRun[browser.id].recordTest(concatTestName(result), isExtraTest(result), result.success); // display error messages
testRun[browser.id].recordTest(concatTestName(result), result.description, isExtraTest(result), result.success); // display error messages

@@ -97,12 +127,3 @@ if (!result.success) {

testFailures[browser.id].push(result);
} // display console logs
if (logs[browser.id] && logs[browser.id].length > 0 && !json) {
console.error();
console.error(concatTestName(result, true));
logs[browser.id].forEach(log => console.error(` ${log.split('\n').join('\n ')}`));
}
delete logs[browser.id];
}; // handle browser errors that do not allow execution of further tests

@@ -125,8 +146,6 @@

this.onBrowserLog = (browser, log, type) => {
if (!logs[browser.id]) {
logs[browser.id] = [];
if (!json) {
const message = typeof log === 'string' ? log : _util.default.inspect(log, false, undefined, true);
console.error(`[console.${type.toLowerCase()}] ${message.split('\n').join('\n ')}`);
}
const message = typeof log === 'string' ? log : _util.default.inspect(log, false, undefined, true);
logs[browser.id].push(`console.${type.toLowerCase()}: ${message}`);
}; // print result when all tests have been executed

@@ -142,3 +161,3 @@

if (json) {
console.log(JSON.stringify(testRun[browser.id], undefined, 2));
console.log(`\n${JSON.stringify(testRun[browser.id], undefined, 2)}`);
} else {

@@ -150,2 +169,6 @@ printTestFailures(formatError, testFailures[browser.id]);

}
if (config.isLocalHistoryEnabled()) {
storeTestRun(config, testRun[browser.id]);
}
};

@@ -152,0 +175,0 @@ };

{
"name": "@skills17/karma-helpers",
"version": "1.1.0",
"version": "1.2.0",
"description": "Provides some karma helpers for usage in a skills competition environment.",

@@ -36,2 +36,4 @@ "main": "lib/index.js",

"@types/jest": "^26.0.20",
"@types/rimraf": "^3.0.0",
"@types/uniqid": "^5.2.0",
"@typescript-eslint/eslint-plugin": "^4.13.0",

@@ -53,2 +55,3 @@ "@typescript-eslint/parser": "^4.13.0",

"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"strip-ansi": "^6.0.0",

@@ -58,5 +61,6 @@ "typescript": "^4.1.3"

"dependencies": {
"@skills17/task-config": "^1.3.4",
"@skills17/test-result-printer": "^1.0.3",
"chalk": "^4.1.0"
"@skills17/task-config": "^2.0.1",
"@skills17/test-result-printer": "^2.0.2",
"chalk": "^4.1.0",
"uniqid": "^5.3.0"
},

@@ -63,0 +67,0 @@ "peerDependencies": {

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