@rpii/wdio-html-reporter
Advanced tools
Comparing version 7.0.0 to 7.7.0
{ | ||
"name": "@rpii/wdio-html-reporter", | ||
"version": "7.0.0", | ||
"description": "WebdriverIO report plugin. Create a basic HTML formatted report. compatible with webdriverio version 6", | ||
"main": "build/index.js", | ||
"types": "wdio-html-reporter.d.ts", | ||
"version": "7.7.0", | ||
"description": "WebdriverIO report plugin. Create an HTML formatted report. compatible with webdriverio version 7", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"scripts": { | ||
"build:test": "babel test/* -d build-test", | ||
"build": "babel src/* -d build/ && babel test/* -d build-test", | ||
"build": "tsc", | ||
"symlink": "npm link", | ||
"use:symlink": "npm link @rpii/wdio-html-reporter", | ||
"clean": "rimraf ./build ./build-test ./reports ./logs", | ||
"clean:build": "rimraf ./build", | ||
"clean": "rimraf ./lib ./reports ./logs", | ||
"clean:build": "rimraf ./lib", | ||
"clean:reports": "rimraf ./reports", | ||
"test": "mocha build-test/**/*.js --require @babel/register", | ||
"test:invalid": "mocha build-test/invalid.test.spec.js --require @babel/register", | ||
"test:reporter": "mocha build-test/reporter.spec.js --require @babel/register", | ||
"clean:logs": "rimraf ./logs", | ||
"test": "mocha ./test/**/*.ts", | ||
"test:invalid": "mocha ./test/invalid.test.spec.ts", | ||
"test:reporter": "mocha ./test/reporter.spec.ts", | ||
"copyjs": "copyfiles --flat --verbose js/*.* ./reports/html-reports/" | ||
@@ -37,3 +37,3 @@ }, | ||
], | ||
"author": "Adrien Ruiz Gauder <caritsqa@gmail.com>", | ||
"author": "Rich Peters <16782353+rpii@users.noreply.github.com>", | ||
"license": "MIT", | ||
@@ -46,4 +46,2 @@ "bugs": { | ||
"@log4js-node/log4js-api": "^1.0.2", | ||
"@rpii/wdio-report-events": "^0.1.3", | ||
"@wdio/reporter": "^7.7.0", | ||
"copyfiles": "^2.3.0", | ||
@@ -53,49 +51,26 @@ "fs-extra": "^9.0.0", | ||
"image-to-base64": "^2.2.0", | ||
"mocha": "^8.4.0", | ||
"moment": "^2.29.1", | ||
"moment-duration-format": "^2.3.2", | ||
"dayjs": "^1.10.5", | ||
"open": "^8.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.14.3", | ||
"@babel/core": "^7.14.3", | ||
"@babel/node": "^7.14.2", | ||
"@babel/plugin-proposal-class-properties": "^7.13.0", | ||
"@babel/plugin-proposal-export-default-from": "^7.12.13", | ||
"@babel/plugin-proposal-function-bind": "^7.12.13", | ||
"@babel/plugin-proposal-optional-catch-binding": "^7.14.2", | ||
"@babel/plugin-syntax-export-default-from": "^7.12.13", | ||
"@babel/preset-env": "^7.14.4", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@babel/register": "^7.13.16", | ||
"babel-plugin-source-map-support": "^2.1.3", | ||
"@types/node": "^14.14.31", | ||
"@types/chai": "^4.2.18", | ||
"@types/mocha": "^8.2.2", | ||
"@wdio/types": "7.7.3", | ||
"@rpii/wdio-report-events": "^0.1.3", | ||
"@wdio/reporter": "^7.7.3", | ||
"ts-node": "^10.0.0", | ||
"tsconfig-paths": "^3.9.0", | ||
"typescript": "^4.3.2", | ||
"concat": "^1.0.3", | ||
"chai": "^4.3.4", | ||
"log4js": "^6.3.0", | ||
"mocha": "^8.4.0", | ||
"rimraf": "^3.0.2" | ||
"rimraf": "^3.0.2", | ||
"@wdio/cli": "^7.7.3", | ||
"typescript-string-operations": "^1.4.1" | ||
}, | ||
"contributors": [ | ||
"Adrien Ruiz Gauder <caritsqa@gmail.com>", | ||
"Gisella Fama <gisella.fama@gmail.com>", | ||
"George Crawford <george.crawford@ft.com>", | ||
"Christian Bromann <github@christian-bromann.com>", | ||
"Markus Benning <ich@markusbenning.de>", | ||
"Rich Peters <16782353+rpii@users.noreply.github.com>", | ||
"Orozbek Askarov <oroz.askarov@gmail.com>" | ||
], | ||
"babel": { | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
] | ||
] | ||
}, | ||
"mocha": { | ||
"ui": "bdd" | ||
} | ||
"Rich Peters <16782353+rpii@users.noreply.github.com>" | ||
] | ||
} |
137
README.md
@@ -1,65 +0,43 @@ | ||
# wdio-html-reporter | ||
#@rpii/wdio-html-reporter | ||
A reporter for webdriver.io which generates a HTML report. | ||
Compatible with webdriverio version 7, with a typescript type file. | ||
Compatible with webdriverio version 7.7 | ||
####Newest Features: | ||
Totally rewritten in typescript. | ||
Update typescript types for webdriverio 7.7 | ||
No more jquery, uses only vanilla js | ||
####New Feature: Styles are provided in a css file and can be modified | ||
No more moment.js dependency | ||
####New Feature: All major vulnerabilities in dependencies fixed | ||
use 'html' for reporter definition | ||
Removed need for global scope reportAggregator in client code | ||
####New Feature: tests are collapsible as well as suites | ||
####New Feature: adds support for creating a PDF file from the html report. | ||
Requires an additional plugin to keep the support lightweight for those that dont want it. | ||
see [@rpii/wdio-html-reporter-pdf](https://www.npmjs.com/package/@rpii/wdio-html-reporter-pdf) | ||
## Information | ||
This project is a fork of [wdio-html-format-reporter](https://www.npmjs.com/package/wdio-html-format-reporter) | ||
That project has not been updated and doesnt work with the latest webdriverio 5.x or 6.x. | ||
This project is a rewrite of [@rpii/wdio-html-reporter](https://www.npmjs.com/package/wdio-html-reporter) | ||
It is written in typescript with many enhancements. | ||
This project does. A pull request was submitted to that project, but it appears to be inactive. | ||
Due to name conflict issues, this package had to be put in my user namespace. it is now in npm. | ||
## Configuration | ||
This module has been tested with mocha and now cucumber. It works with both. | ||
The following code shows the default wdio test runner configuration. Just add an HtmlReporter object as another reporter to the reporters array: | ||
## Installation | ||
###A functioning wdio.config.ts is provided in the [/samples/wdio.config.ts](/samples/wdio.config.ts) | ||
The easiest way is to keep the `@rpii/wdio-html-reporter` as a devDependency in your package.json: | ||
below are snippets from that file | ||
```javascript | ||
{ | ||
"devDependencies": { | ||
"@rpii/wdio-html-reporter": "~7.0.0" | ||
} | ||
} | ||
``` | ||
```typescript | ||
// wdio.config.ts | ||
import {ReportAggregator, HtmlReporter} from '@wdio/html-reporter'; | ||
let reportAggregator: ReportAggregator; | ||
Or, you can simply do it with: | ||
``` | ||
yarn add @rpii/wdio-html-reporter --dev | ||
``` | ||
## Configuration | ||
The following code shows the default wdio test runner configuration. Just add an HtmlReporter object as another reporter to the reporters array. Syntax shown requires babel: | ||
```javascript | ||
// wdio.conf.js | ||
import { ReportAggregator, HtmlReporter} from '@rpii/wdio-html-reporter' ; | ||
module.exports = { | ||
const BaseConfig: WebdriverIO.Config = { | ||
reporters: ['spec', | ||
[HtmlReporter, { | ||
debug: true, | ||
["html", { | ||
outputDir: './reports/html-reports/', | ||
@@ -103,3 +81,3 @@ filename: 'report.html', | ||
let reportAggregator = new ReportAggregator({ | ||
reportAggregator = new ReportAggregator({ | ||
outputDir: './reports/html-reports/', | ||
@@ -109,9 +87,5 @@ filename: 'master-report.html', | ||
browserName : capabilities.browserName, | ||
collapseTests: true, | ||
// to use the template override option, can point to your own file in the test project: | ||
// templateFilename: path.resolve(__dirname, '../template/wdio-html-reporter-alt-template.hbs') | ||
}); | ||
collapseTests: true | ||
}); | ||
reportAggregator.clean() ; | ||
global.reportAggregator = reportAggregator; | ||
}, | ||
@@ -121,3 +95,3 @@ | ||
(async () => { | ||
await global.reportAggregator.createReport(); | ||
await reportAggregator.createReport(); | ||
})(); | ||
@@ -134,4 +108,5 @@ }, | ||
const log4js = require('@log4js-node/log4js-api'); | ||
const logger = log4js.getLogger('default'); | ||
const logger = log4js.getLogger(this.options.debug ? 'debug' : 'default'); | ||
@@ -143,54 +118,8 @@ ### To use a custom handlebars template for reports | ||
## Add Message and Screenshots to the Html Report: | ||
### To generate a pdf file from this report | ||
## To show messages in the html report | ||
Requires an additional plugin to keep the support lightweight for those that dont want it. | ||
see [@rpii/wdio-html-reporter-pdf](https://www.npmjs.com/package/@rpii/wdio-html-reporter-pdf) | ||
Add the function below to your test code and call it when you want to output a message | ||
```javascript | ||
logMessage(message) { | ||
process.emit('test:log', message); | ||
} | ||
``` | ||
## To take Screenshots: | ||
Add a function that you can call from anywhere in your test: | ||
``` | ||
takeScreenshot(message) { | ||
const timestamp = moment().format('YYYYMMDD-HHmmss.SSS'); | ||
fs.ensureDirSync('reports/html-reports/screenshots/'); | ||
const filepath = path.join('reports/html-reports/screenshots/', timestamp + '.png'); | ||
this.browser.saveScreenshot(filepath); | ||
this.logMessage(message) ; | ||
process.emit('test:screenshot', filepath); | ||
return this; | ||
} | ||
``` | ||
## To take a screenshot after any test fails: | ||
``` | ||
wdio.conf.js | ||
afterTest: function (test) { | ||
const path = require('path'); | ||
const moment = require('moment'); | ||
// if test passed, ignore, else take and save screenshot. | ||
if (test.passed) { | ||
return; | ||
} | ||
const timestamp = moment().format('YYYYMMDD-HHmmss.SSS'); | ||
const filepath = path.join('reports/html-reports/screenshots/', timestamp + '.png'); | ||
browser.saveScreenshot(filepath); | ||
process.emit('test:screenshot', filepath); | ||
}, | ||
``` | ||
## To take a screenshot after each test completes: | ||
Set the option useOnAfterCommandForScreenshot to true | ||
This option is used if you are not using either of the screenshot options above. | ||
## Sample Output: | ||
@@ -229,3 +158,3 @@ | ||
let reportAggregator = new ReportAggregator({ | ||
reportAggregator = new ReportAggregator({ | ||
outputDir: './reports/html-reports/', | ||
@@ -241,4 +170,4 @@ filename: 'master-report.html', | ||
global.reportAggregator = reportAggregator; | ||
reportAggregator = reportAggregator; | ||
}, | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
7
23
1396
164272
166
2
+ Addeddayjs@^1.10.5
+ Addeddayjs@1.11.13(transitive)
+ Addedyargs-parser@20.2.9(transitive)
- Removed@rpii/wdio-report-events@^0.1.3
- Removed@wdio/reporter@^7.7.0
- Removedmocha@^8.4.0
- Removedmoment@^2.29.1
- Removedmoment-duration-format@^2.3.2
- Removed@rpii/wdio-report-events@0.1.4(transitive)
- Removed@sindresorhus/is@4.6.0(transitive)
- Removed@szmarczak/http-timer@4.0.6(transitive)
- Removed@types/cacheable-request@6.0.3(transitive)
- Removed@types/diff@5.2.3(transitive)
- Removed@types/http-cache-semantics@4.0.4(transitive)
- Removed@types/keyv@3.1.4(transitive)
- Removed@types/node@18.19.65(transitive)
- Removed@types/object-inspect@1.13.0(transitive)
- Removed@types/responselike@1.0.3(transitive)
- Removed@types/supports-color@8.1.3(transitive)
- Removed@types/tmp@0.2.6(transitive)
- Removed@ungap/promise-all-settled@1.1.2(transitive)
- Removed@wdio/reporter@7.33.0(transitive)
- Removed@wdio/types@7.33.0(transitive)
- Removedansi-colors@4.1.1(transitive)
- Removedansi-regex@3.0.1(transitive)
- Removedanymatch@3.1.3(transitive)
- Removedargparse@2.0.1(transitive)
- Removedbinary-extensions@2.3.0(transitive)
- Removedbraces@3.0.3(transitive)
- Removedbrowser-stdout@1.3.1(transitive)
- Removedcacheable-lookup@5.0.4(transitive)
- Removedcacheable-request@7.0.4(transitive)
- Removedcamelcase@6.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedchokidar@3.5.1(transitive)
- Removedclone-response@1.0.3(transitive)
- Removeddebug@4.3.1(transitive)
- Removeddecamelize@4.0.0(transitive)
- Removeddecompress-response@6.0.0(transitive)
- Removeddefer-to-connect@2.0.1(transitive)
- Removeddiff@5.0.05.2.0(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedescape-string-regexp@4.0.0(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfind-up@5.0.0(transitive)
- Removedflat@5.0.2(transitive)
- Removedfs-extra@11.2.0(transitive)
- Removedfsevents@2.3.3(transitive)
- Removedget-stream@5.2.0(transitive)
- Removedglob@7.1.6(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedgot@11.8.6(transitive)
- Removedgrowl@1.10.5(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedhe@1.2.0(transitive)
- Removedhttp-cache-semantics@4.1.1(transitive)
- Removedhttp2-wrapper@1.0.3(transitive)
- Removedis-binary-path@2.1.0(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedis-plain-obj@2.1.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjs-yaml@4.0.0(transitive)
- Removedjson-buffer@3.0.1(transitive)
- Removedkeyv@4.5.4(transitive)
- Removedlocate-path@6.0.0(transitive)
- Removedlog-symbols@4.0.0(transitive)
- Removedlowercase-keys@2.0.0(transitive)
- Removedmimic-response@1.0.13.1.0(transitive)
- Removedminimatch@3.0.4(transitive)
- Removedmocha@8.4.0(transitive)
- Removedmoment@2.30.1(transitive)
- Removedmoment-duration-format@2.3.2(transitive)
- Removedms@2.1.22.1.3(transitive)
- Removednanoid@3.1.20(transitive)
- Removednormalize-path@3.0.0(transitive)
- Removednormalize-url@6.1.0(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedp-cancelable@2.1.1(transitive)
- Removedp-limit@3.1.0(transitive)
- Removedp-locate@5.0.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedquick-lru@5.1.1(transitive)
- Removedrandombytes@2.1.0(transitive)
- Removedreaddirp@3.5.0(transitive)
- Removedresolve-alpn@1.2.1(transitive)
- Removedresponselike@2.0.1(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedserialize-javascript@5.0.1(transitive)
- Removedstring-width@2.1.1(transitive)
- Removedstrip-ansi@4.0.0(transitive)
- Removedstrip-json-comments@3.1.1(transitive)
- Removedsupports-color@7.2.08.1.1(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedundici-types@5.26.5(transitive)
- Removedwhich@2.0.2(transitive)
- Removedwide-align@1.1.3(transitive)
- Removedworkerpool@6.1.0(transitive)
- Removedyargs-parser@20.2.4(transitive)
- Removedyargs-unparser@2.0.0(transitive)
- Removedyocto-queue@0.1.0(transitive)