Giter Site home page Giter Site logo

testrunner's Introduction

TestRunner

This module exposes a wrapper testRunner around the ACT Rules Testcases for each of the rules in ACT Rules Repository, thereby allowing to execute a given evaluation function against the test case as a document context.

Usage of TestRunner

Code snippet, showing various ways to use the testRunner.

const testRunner = require('testrunner')
// testrunner refers to file entry file `src/index.js`

// execute async
const results = await testRunner(config);

// or execute as a promise chain
testRunner(options)
  .then(results => {
    // explore results
  })
  .catch(error => {
    // handle error
  })

Configuration Object for TestRunner

Members of the config object passed to the testRunner.

Name Type Default Value Description
config.debug Boolean false (Optional) Runs the testRunner in debug mode, which launches each test case page in a chromium (non-headless) mode
config.injectScripts Array<String>[] undefined (Optional) A list of path or url of scripts to be injected into the puppeteer page context
config.globals Object undefined (Mandatory) An object containing key-value pairs of variables or functions to be mounted as a global variable in the puppeteer page context for usage by the evaluate function
config.globals.rulesMap Object - (Mandatory) An object containing key-value pairs of ruleId of each act-r rule mapped to a uniqueId of rule(s) to run against a chosen test tool
config.evaluate Function -` (Mandatory) A function containing logic to be evaluated on the page context

An example configuration object is as below:

const config = {
  debug: false,
  injectScripts: [
    'https://code.jquery.com/jquery-3.3.1.min.js'
    // can be relative paths to any scripts as well, (eg: `../../myscript.js`)
  ],
  globals: {
    rulesMap
    // this can also contain functions to be made available on the page context
    // eg: myLogger: function(data) { console.log(data) }
  },
  evaluate: () => {
    // logic to be evaluated within the page context.
  }
}

Rules Mapping

To help define a 1 to 1 or 1 to Many relationship between ACT Rules and the test tool, an object of key-value pairs must be defined with the key rulesMap in the config.globals.

A sample template to build mappings, showing each of the ACT Rules with their ids, can be seen here

An example mapping is as below:

const rulesMap = {
  'SC1-3-5-autocomplete-valid': ['autocomplete-valid']
}

If no mapping is defined an error is thrown by the module.

Development & Contributing

js-standard-style

Some notable libraries used to build this module are:

  • axios for XMLHttpRequest management.
  • puppeteer for executing a given test case in a headless chromium page context.
  • jest for testing.

For a full list of dependencies refer package.json

Directory Structure

  • src directory contains the library code.
  • test directory contains testing code.
  • example directory shows a sample usage of the module.

NPM Scripts

There is no build mechanism for this module. The entry point is set to src/index.js

  • npm run dev runs prettier to format, then lint, then test, followed by example usage.
  • npm run lint runs eslint across all .js files.
  • npm run test runs test and reports coverage both in terminal and coverage directory.
  • npm run format runs prettier on the code base to format to standard code style.

For a full list of scripts refer package.json

testrunner's People

Contributors

jeeyyy avatar wilcofiers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.