npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@testwizard/test

v3.8.1

Published

> Javascript language support for testing different kinds of devices using testwizard

Downloads

307

Readme

Testwizard - Test

Javascript language support for testing different kinds of devices using testwizard

npm (scoped) lerna

Usage

Use this package in combination with one (or more) of the specific device packages

Sidecar file

The testwizard manager enables a single script to be run on different devices with (optionally) different sets of parameters. To enable this from any IDE a sidecar file (in json format) is used . By default the name of the sidecar file is the same as this script, but with a .json extension. If this file is not found default.json in the same folder as the script will be used when available. A command-line-argument (--sidecar or -s) can be used to instruct the usage of a different file.

This json file has the following attributes:

  • tester: The name of the tester (optional)
  • parameters: An array of parameters (optional)
    • name: The name of the parameter
    • value: The value for the parameter
  • customProperties: An object holding the custom property values (optional)
  • resources: An array of resources
    • category: The category of the testobject
    • name: The name of the testobject
    • id: The id of the testobject
    • customProperties: An object holding the custyom property values of the testobject (optional)
  • outputFolder: The folder where the log files should be written (optional)

Parameters

Every parameter will be made available as a field of the parameters property of the session object.

const param1 = session.parameters.param1;

Resources

All resources will be acquired (and thus locked) at the start of a test run and will be released when the script ends. To execute a command on a testobject it must be referenced (constructed), when doing this, the name of the resource will be used, while the id corresponds to the actual device.

const mobile = await Mobile.create(session, "Mobile");
let result = await mobile.initDriver();

CustomProperties

Custom properties are maintained in the Testwizard manager and can be set on Sessions and TestObjects. These custom properties can be accessed from within a script.

const sessionProperty = session.customProperties.myString;
const testObjectProperty = mobile.customProperties.myNumber;

Output folder

When running a test all actions are logged (testrun.log) and so is the result (result.log). By default the location of these files is a timestamp based folder within the runs folder. If a different location is preferred, this can be configured in the outputfolder attribute.

Session

When the script is executed (run or debug), a new session is created, and all resources will be locked If any of the resources is allready in use, a session cannot be setup and an error will be thrown. The session is destroyed when the script ends. At this point the resources will be released and available for other script runs.

More information about the session can be read from the info attribute:

  • info
    • scriptFilePath: The full path of the script file
    • scriptFileName: The file name of the script file
    • storagePath: The directory where the output will be written
    • tester: The name of the tester
  • info.environment
    • scriptsBasePath: The root directory where all scripts are stored
    • storageBasePath: The root directory where the output is written
    • ocrEngine: The name of the ocr engine being used
    • testWizardVersion: The version of testwizard being used
  • info.session (optional: only when run from within the manager)
    • id: The unique identifier of the session in the manager
    • name: The name of the session
    • scriptIndex: The index of the script within the session

Results

The outcome of a script run can be either Pass, Fail or Error. During a script run multiple results can be reported, this can be done in 2 different ways:

  1. addPass / addFail: reports a pass or fail but does not post it to the server
  2. setResult: reports a pass / fail /error and posts it to the server
let result = await mobile.initDriver();
if (result.success)
     session.addPass(result.message);
else
     session.addFail(result.message);
let result = await mobile.initDriver();
if (result.success)
     await session.setResult(Testwizard.ResultCodes.PASS, result.message);
else
     await session.setResult(Testwizard.ResultCodes.FAIL, result.message);

Sample script

javascript (sample.js)

'use strict';

const Testwizard = require("@testwizard/test");
const Mobile = require("@testwizard/mobile");
const SetTopBox = require("@testwizard/set-top-box");

async function test() {
    console.log("-- Create Session ---");
    const session = await Testwizard.createSession();

    console.log("-- Parameter and Custom properties ---");
    console.log("Parameters:");
    console.log("  param1 = " + session.parameters.param1);
    console.log("  param2 = " + session.parameters.param2);
    console.log("Custom Properties:");
    console.log("  myString = " + session.customProperties.myString);
    console.log("  myNumber = " + session.customProperties.myNumber);

    console.log("-- Session info ---");
    console.log("  info.scriptFilePath = " + session.info.scriptFilePath);
    console.log("  info.scriptFileName = " + session.info.scriptFileName);
    console.log("  info.storagePath = " + session.info.storagePath);
    console.log("  info.tester = " + session.info.tester);
    console.log("  info.environment.scriptsBasePath = " + session.info.environment.scriptsBasePath);
    console.log("  info.environment.storageBasePath = " + session.info.environment.storageBasePath);
    console.log("  info.environment.ocrEngine = " + session.info.environment.ocrEngine);
    console.log("  info.environment.testWizardVersion = " + session.info.environment.testWizardVersion);
    if (session.info.session !== null)
    {
        console.log("Script was started by the manager:");
        console.log("  info.session.id = " + session.info.session.id);
        console.log("  info.session.name = " + session.info.session.name);
        console.log("  info.session.scriptIndex = " + session.info.session.scriptIndex);
    }

    console.log("-- Create Mobile test object ---");
    const mobile = await Mobile.create(session, "Mobile");

    console.log("-- Mobile test object info ---");
    console.log("  id = " + mobile.info.id);
    console.log("  name = " + mobile.info.name);
    console.log("  category = " + mobile.info.category);
    console.log("  device.serialNo = " + mobile.info.device.serialNo);
    console.log("  device.hardwareVersion = " + mobile.info.device.hardwareVersion);
    console.log("  device.softwareVersion = " + mobile.info.device.softwareVersion);
    console.log("  device.description = " + mobile.info.device.description);
    console.log("  device.vendor.name = " + mobile.info.device.vendor.name);
    console.log("  device.vendor.modelName = " + mobile.info.device.vendor.modelName);
    console.log("  device.vendor.serialNo = " + mobile.info.device.vendor.serialNo);
    console.log("Custom Properties:");
    console.log("  myString = " + mobile.customProperties.myString);
    console.log("  myNumber = " + mobile.customProperties.myNumber);

    console.log("- mobile: initDriver");
    let result = await mobile.initDriver();
    console.log(result.message);
    if (!result.success)
        session.addFail(result.message);

    console.log("-- Create Set-top box test object ---");
    const setTopBox = await SetTopBox.create(session, "STB");

    console.log("- stb: sendRCKey");
    result = await setTopBox.sendRCKey("menu");
    console.log(result.message);
    if (!result.success)
        session.addFail(result.message);

    if (!(session.hasFails || session.hasErrors))
        session.addPass("Test was successful");
}

test();

sidecar file (sample.json)

{
    "tester": "Some tester",
    "parameters": [
        { 
            "name": "param1", 
            "value": "value1"
        },
        { 
            "name": "param2", 
            "value": "value2"
        }
    ],
    "customProperties": {
        "myString": "test",
        "myNumber": 123.4
    },
    "resources": [
        { 
            "category": "MOBILE", 
            "name": "Mobile", 
            "id": "Mobile 1",
            "customProperties": {
                "myString": "Just testing",
                "myNumber": 456
            }
        },
        { 
            "category": "STB", 
            "name": "STB", 
            "id": "SetTopBox 1"
        }
    ],
    "outputFolder": "c:\\temp"
}

Compatibility

The version is compatible with testwizard version 3.7

License

Testwizard licensing