@wdio/concise-reporter
Advanced tools
Comparing version 9.0.0-alpha.426 to 9.0.0
@@ -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" | ||
} |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
0
7926
138
+ Added@types/node@20.17.6(transitive)
+ Added@wdio/logger@9.0.0(transitive)
+ Added@wdio/reporter@9.0.0(transitive)
+ Added@wdio/types@9.0.0(transitive)
+ Addedansi-regex@6.1.0(transitive)
+ Addeddiff@5.2.0(transitive)
+ Addedloglevel@1.9.2(transitive)
+ Addedloglevel-plugin-prefix@0.8.4(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedstrip-ansi@7.1.0(transitive)
+ Addedundici-types@6.19.8(transitive)
Updated@wdio/reporter@9.0.0
Updated@wdio/types@9.0.0