@boozt/webtest-runner

0.2.1 • Public • Published

Test runner

When it comes to working on complex or sensitive UI you probably want to cover it with some tests. The webtest-runner allows you to invoke your tests synchronously and get some information about the process. Therefore, you can create awesome, simple and convenient tests.

Usage

Add node ./node_modules/@boozt/webtest-runner {path} to the script section in your package.json. Where the {path} is a path to the file which imports all of your tests.

You can also specify which of your tests should be performed by adding the filter option with the names of your test. For instance: node webtest-runner ./web/tests/list.js filter testCheckout testCart

In this example, of all existing tests specified in list.js, only testCheckout and testCart will be executed.

{path}

This file can look like:

const testChekout = require('./tests/testChekout');
const testCart = require('./tests/testCart')

/**
 * Here you can add your tests
 */
module.exports = {
    testChekout,
    testCart
};

Tests and cases

// ./tests/testCart.js


const { Builder, By } = require('selenium-webdriver');
const assert = require('assert');
const { getUrl } = require('../config');

// URL
const url = getUrl('/cart');

// Selectors
const modalClass = 'cart-modal';

/**
 * Test modal exists
 *
 * The test object must contain ONLY test cases
 */
module.exports = {

    /**
     * Case 1
     *
     * Open popup
     */
    testOpenPopup: async function() {
        let driver = await new Builder().forBrowser('chrome').build();
        try {
            await driver.get(url);
            
            const $modal = await driver.findElement(By.className(modalClass));
            const _class = await $form.getAttribute('class');
            assert.strictEqual(modalClass, _class, 'The modal is not shown');

        } finally {
            await driver.quit();
        }
    }
}

beforeTest and afterTest

If you need to perform some actions before or/and after your test you can use these functions in your test object.

Wherever you place these functions in your test object it ensures that beforeTest will be invoked first and afterTest last.

Package Sidebar

Install

npm i @boozt/webtest-runner

Weekly Downloads

335

Version

0.2.1

License

MIT

Unpacked Size

6.03 kB

Total Files

6

Last publish

Collaborators

  • misoboozt
  • mgro
  • bang.boozt
  • mykr
  • boozt-platform
  • yebl