Socket
Socket
Sign inDemoInstall

@boozt/webtest-runner

Package Overview
Dependencies
2
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @boozt/webtest-runner

Use the webtest-runner to run your test synchronously. This is a simple module that you can easily use with Selenium.


Version published
Weekly downloads
1.1K
decreased by-40.76%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 29 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc