0.4.1 • Published 3 years ago

automation.report v0.4.1

Weekly downloads
126
License
ISC
Repository
github
Last release
3 years ago

automation.report

javascript library to create simple html report for api or ui test execution

usage

let report = require("automation.report").default;

usage typescript:

import report from "automation.report";

Sample Report: http://www.myappquality.com/

Current date time is used to create report folder. To delete all report folders before any test execution call deleteReportFolder

report.deleteReportFolder();

Default name of the html file generate is report.html. If you want rename this call setFileName and pass only the name, html extension is appended

report.setFileName('custom report name');

Default title of the html report is Execution Results. If you want rename this call setTitle

report.setTitle('Results for Production Smoke Test');

To capture screenshots assign webdriver istance to driver property of report object.

report.driver = selenium webdriver instance

if you ar using protractor:

report.driver = browser.driver;

There is a flag to disable screenshot if need be. It is true by default

report.takeScreenShot = false;

To start capturing test data call startTest method and pass test name and description as parameters. HTML report gets generated/updated every time endTest method is called.

report.startTest(string,string);
example: report.startTest('verify login','test to verify user can login');

To add test step, call addTestStep method. This method has boolean parameters based on different needs. To add a simple step, call below method.

report.addTestStep(string,null);
example: report.addTestStep('logged in with username and password',null);

For api tests to add test step with request or response. Pass true as third parameter.

report.addTestStep(string,null,true);
ex: report.addTestStep('request or response data',null,true);

To add test step with an error, call addTestStep and pass error/exception object. This will ensure this step is marked in red in the html report

report.addTestStep(string,object);
ex: report.addTestStep('step description','exception occured');
ex: report.addTestStep('step description',new Error('some error'));

similarly for api tests, to add test step with error or exception

report.addTestStep(string,object,true);
ex: report.addTestStep('step description','pass error object here',true);

To assert two values are equal, call strictEqual method.

report.strictEqual(string,expected,actual);
ex: report.strictEqual('verify two strings are equal','abc','ABC');

if the values are equal, the step is marked as green. If the values are not equal the step is marked in red.

To assert two values are not equal, call notStrictEqual method.

report.notStrictEqual(string,expected,actual);
ex: report.notStrictEqual('verify two strings are equal','abc','ABC');

if the values are not equal, the step is marked as green. If the values are equal the step is marked in red.

To end the test call endTest

report.endTest();

To get the object of tests call getSuite

let suite = report.getSuite();

sample code to generate html report:

let report = require("automation.report").default;
report.deleteReportFolder();
report.startTest('report library features','test to show report library features');
report.addTestStep('this is addTestStep method',null);
report.addTestStep('this is addTestStep with api true',null,true);
report.strictEqual('verify abc = ABC','abc','ABC');
report.notStrictEqual('verify abc not equal to abc','abc','abc');
report.strictEqual('verify abc = abc','abc','abc');
report.notStrictEqual('verify abc not equal to ABC','abc','ABC');
report.endTest();

To add this report as custom reporter for protractor and jasmine, in your conf file add:

const report = require("automation.report").default;
const CustomJasmineReporter = require("automation.report").CustomJasmineReporter;

under onPrepare function add below:
onPrepare: function(){
    report.driver = this.browser.driver;
    report.deleteReportFolder();
    jasmine.getEnv().addReporter(new CustomJasmineReporter());
    //pass a true flag to CustomJasmineReporter to group tests by describe and it block becomes a test step)
    jasmine.getEnv().addReporter(new CustomJasmineReporter(true));
}
0.4.1

3 years ago

0.3.9

3 years ago

0.3.8

3 years ago

0.4.0

3 years ago

0.3.7

3 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago