Wondering what’s next for npm?Check out our public roadmap! »

wdio-allure-tsTypeScript icon, indicating that this package has built-in type declarations

2.1.3 • Public • Published

WebdriverIO + Allure reporter + TypeScript


Build Status

Util that blends WebdriverIO, TypeScript and Allure Reporter in to end-to-end UI testing solution. It wraps the most common WebdriverIO actions, generating intuitive error messages in case of failure, custom logs for the Allure Reporter, more validations for enhanced stability, and last, but not least, IntelliSense.

##Getting Started You need to install Java JDK 8 or above, NodeJS

Supported browsers Chrome

####Install and run tests yarn install all dependencies

yarn start:sampleApp spin up the sample app page for testing

yarn test execute all tests

yarn spec <spec name> to execute specific spec file

Environment variables

PRINT_LOGS_TO_CONSOLE - false by default. only enabled in dev configuration, since parallel tests execution will log to same terminal

DEFAULT_TIME_OUT - timeout for webdriverIO actions. Default value 60 seconds

Project Structure

Reporter

Logs to both terminal and allure report

BrowserUtils

webdriverIO actions wrapper

TestUtils

Common utils for tests such as getRandomString()

SpecialKeys

Holds keyboard special keys

GitUtils

Common utils for git like get the last merged files

TestRailUtils

Common utils for testrail api like update tests field

Example for TestRailUtils

//Update the Automation field for the last merged tests to Automated

try {
        const lastMergedTestsIds = GitUtils.getLastMergedTestsIds();
        TestRailUtil.setTestsAsAutomatedInTestrail(lastMergedTestsIds);
    } catch (error) {
        console.log(error);
    }

Example With Pure WebdriverIO

Now take a look at an example of an action that, after validating that a particular element is visible, clicks it, logs every step to the Reporter, and throws meaningful errors for failures, if any.

 const selector: string = "someSelector";
 logger(`Click an element with selector: ${selector}`);
 try {
   logger(`Validate element with selector ${selector} is displayed`);
   browser.isDisplayed(selector);
 } catch (error) {
   throw new Error(`Tried to click not visible element, ${error}`);
 }

 try {
   logger("Perform click action");
   browser.click(selector);
 } catch (error) {
   throw new Error(
     `Failed to click an element by given selector ${selector}. ${error}`
   );
 }

Example with wdio-allure-ts:

const selector: string = "someSelector";
BrowserUtils.click(selector);

You can see that wdio-allure-ts offers the same capabilities with much cleaner code. Because it automatically handles logging and error reporting, developers can focus on testing the business logic. You can add more report logs with a simple Reporter API for log levels: step, debug, error, info, and warning. The logs are displayed on the terminal and reflected in the report. Example:

import { Reporter } from 'wdio-allure-ts';
Reporter.step('Step log entry');
Reporter.error('Error log entry');

Terminal Output

Terminal Output Note the difference in the highlighted areas between the original report and the one created with wdio-allure-ts. Original Report

Original Report

wdio-allure-ts Report(live report example):

wdio-allure-ts Report

CLI execution

Added an option to execute tests with cli.

cmd:

node ./lib/helpers/runner.js

That uses default wdio configuration wdio.default.conf.js if no parameters passed.

Additional available cli inputs:

--specs "test1.js" "test2.js - tests path separated by space

--config "customConfig.js" - path to custom config for wdio execution

CLI example:

node ./lib/helpers/runner.js --specs 'specs/TEST1.js' 'specs/TEST2.js' --config 'customConf.js'

Ready to Try?

Check out a sample project with a quick introduction to our framework and its usage on a real-world application

Install

npm i wdio-allure-ts

DownloadsWeekly Downloads

155

Version

2.1.3

License

MIT

Unpacked Size

109 kB

Total Files

32

Last publish

Collaborators

  • avatar