Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wdio/concise-reporter

Package Overview
Dependencies
Maintainers
3
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wdio/concise-reporter - npm Package Compare versions

Comparing version 9.0.0-alpha.426 to 9.0.0

198

build/index.js

@@ -1,102 +0,98 @@

import WDIOReporter from '@wdio/reporter';
import chalk from 'chalk';
export default class ConciseReporter extends WDIOReporter {
// keep track of the order that suites were called
_suiteUids = [];
_suites = [];
_stateCounts = { failed: 0 };
constructor(options) {
// write to output stream by default
super(Object.assign({ stdout: true }, options));
// src/index.ts
import WDIOReporter from "@wdio/reporter";
import chalk from "chalk";
var ConciseReporter = class extends WDIOReporter {
// keep track of the order that suites were called
_suiteUids = [];
_suites = [];
_stateCounts = { failed: 0 };
constructor(options) {
super(Object.assign({ stdout: true }, options));
}
onSuiteStart(suite) {
this._suiteUids.push(suite.uid);
}
onSuiteEnd(suite) {
this._suites.push(suite);
}
onTestFail() {
this._stateCounts.failed++;
}
onRunnerEnd(runner) {
this.printReport(runner);
}
/**
* Print the Concise report to the screen
* @param {Object} runner Wdio runner
*/
printReport(runner) {
const header = chalk.yellow("========= Your concise report ==========");
const output = [
this.getEnviromentCombo(runner.capabilities),
this.getCountDisplay(),
...this.getFailureDisplay()
];
this.write(`${header}
${output.join("\n")}
`);
}
/**
* Get the display for failing tests
* @return {String} Count display
*/
getCountDisplay() {
const failedTestsCount = this._stateCounts.failed;
return failedTestsCount > 0 ? `\u274C Test${failedTestsCount > 1 ? "s" : ""} failed (${failedTestsCount}):` : this.counts.tests === 0 ? "\u274C Failed to setup tests, no tests found" : "\u2705 All went well!";
}
/**
* Get display for failed tests, e.g. stack trace
* @return {Array} Stack trace output
*/
getFailureDisplay() {
const output = [];
this.getOrderedSuites().map((suite) => suite.tests.map((test) => {
if (test.state === "failed") {
output.push(
` Fail : ${chalk.red(test.title)}`,
// @ts-ignore
` ${test.error.type} : ${chalk.yellow(test.error?.message)}`
);
}
}));
return output;
}
/**
* Get suites in the order they were called
* @return {Array} Ordered suites
*/
getOrderedSuites() {
const orderedSuites = [];
this._suiteUids.map((uid) => this._suites.map((suite) => {
if (suite.uid === uid) {
orderedSuites.push(suite);
}
}));
return orderedSuites;
}
/**
* Get information about the enviroment
* @param {Object} caps Enviroment details
* @param {Boolean} verbose
* @return {String} Enviroment string
*/
getEnviromentCombo(caps) {
const device = caps.deviceName || caps["appium:deviceName"] || caps.device;
const browser = caps.browserName || caps.browser;
const version = caps.browserVersion || caps.version || caps["appium:platformVersion"] || caps.browser_version;
const platform = caps.os ? caps.os + " " + caps.os_version : caps.platform || caps.platformName;
if (device) {
const program = (caps["appium:app"] || "").replace("sauce-storage:", "") || caps.browserName;
const executing = program ? `executing ${program}` : "";
return `${device} on ${platform} ${version} ${executing}`.trim();
}
onSuiteStart(suite) {
this._suiteUids.push(suite.uid);
}
onSuiteEnd(suite) {
this._suites.push(suite);
}
onTestFail() {
this._stateCounts.failed++;
}
onRunnerEnd(runner) {
this.printReport(runner);
}
/**
* Print the Concise report to the screen
* @param {Object} runner Wdio runner
*/
printReport(runner) {
const header = chalk.yellow('========= Your concise report ==========');
const output = [
this.getEnviromentCombo(runner.capabilities),
this.getCountDisplay(),
...this.getFailureDisplay()
];
this.write(`${header}\n${output.join('\n')}\n`);
}
/**
* Get the display for failing tests
* @return {String} Count display
*/
getCountDisplay() {
const failedTestsCount = this._stateCounts.failed;
return failedTestsCount > 0
? `❌ Test${failedTestsCount > 1 ? 's' : ''} failed (${failedTestsCount}):`
: this.counts.tests === 0
? '❌ Failed to setup tests, no tests found'
: '✅ All went well!';
}
/**
* Get display for failed tests, e.g. stack trace
* @return {Array} Stack trace output
*/
getFailureDisplay() {
const output = [];
this.getOrderedSuites().map(suite => suite.tests.map(test => {
if (test.state === 'failed') {
output.push(` Fail : ${chalk.red(test.title)}`,
// @ts-ignore
` ${test.error.type} : ${chalk.yellow(test.error?.message)}`);
}
}));
return output;
}
/**
* Get suites in the order they were called
* @return {Array} Ordered suites
*/
getOrderedSuites() {
const orderedSuites = [];
this._suiteUids.map(uid => this._suites.map(suite => {
if (suite.uid === uid) {
orderedSuites.push(suite);
}
}));
return orderedSuites;
}
/**
* Get information about the enviroment
* @param {Object} caps Enviroment details
* @param {Boolean} verbose
* @return {String} Enviroment string
*/
getEnviromentCombo(caps) {
// @ts-expect-error `deviceName` and `device` are outdated JSONWP caps
const device = caps.deviceName || caps['appium:deviceName'] || caps.device;
// @ts-expect-error `browser` is an outdated JSONWP cap
const browser = caps.browserName || caps.browser;
// @ts-expect-error `version` and `browser_version` are outdated JSONWP caps
const version = caps.browserVersion || caps.version || caps['appium:platformVersion'] || caps.browser_version;
// @ts-expect-error `os`, `os_version` and `platform` are outdated JSONWP caps
const platform = caps.os ? (caps.os + ' ' + caps.os_version) : (caps.platform || caps.platformName);
// mobile capabilities
if (device) {
const program = (caps['appium:app'] || '').replace('sauce-storage:', '') || caps.browserName;
const executing = program ? `executing ${program}` : '';
return `${device} on ${platform} ${version} ${executing}`.trim();
}
return browser
+ (version ? ` (v${version})` : '')
+ (platform ? ` on ${platform}` : '');
}
}
return browser + (version ? ` (v${version})` : "") + (platform ? ` on ${platform}` : "");
}
};
export {
ConciseReporter as default
};
{
"name": "@wdio/concise-reporter",
"version": "9.0.0-alpha.426+d760644c4",
"version": "9.0.0",
"description": "A concise reporter for WebdriverIO",

@@ -27,9 +27,11 @@ "author": "Christian Bromann <mail@bromann.dev>",

"exports": {
".": "./build/index.js",
"./package.json": "./package.json"
".": {
"types": "./build/index.d.ts",
"import": "./build/index.js"
}
},
"typeScriptVersion": "3.8.3",
"dependencies": {
"@wdio/reporter": "9.0.0-alpha.426+d760644c4",
"@wdio/types": "9.0.0-alpha.426+d760644c4",
"@wdio/reporter": "9.0.0",
"@wdio/types": "9.0.0",
"chalk": "^5.0.1",

@@ -41,3 +43,3 @@ "pretty-ms": "^9.0.0"

},
"gitHead": "d760644c4c6e1ef910c0bee120cb422e25dbbe06"
"gitHead": "957693463371a4cb329395dcdbce8fb0c930ab93"
}
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