Skip to content

JScript Language Reference

Important

Starting from Rapise 8.0, the default JavaScript engine used is NodeJS v14.15.3 runtime. Starting from Rapise 8.1, the default JavaScript engine used is NodeJS v18.18.0 runtime.

In versions prior to 6.7, Rapise used Microsoft JScript with WScript as the only available JavaScript engine. This document provides a language reference for that older version.

If you have existing tests or testing frameworks that are not compatible with NodeJS, you have the option to switch back to using WScript.

You can set the desired engine in two locations:

  1. In the Test Settings (choose from Default, Node, WScript). The Default option uses the engine defined in the Global Options.

  2. In the Global Options (choose from Default, Node, WScript). The Default option means Node.

NodeJS Support Features and Limitations

Features

  1. NodeJS v18 contains most of latest features of JavaScript including EcmaScript2015 (ES6) and beyond. You may see more detailed list of features here.
  2. You may find the most complete and up to date language reference at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference.
  3. You may use most of available npm packages in your test scripts. You may include node_modules folders in the root of your testing framework (i.e. %WORKDIR%\node_modules).

Limitations

  1. NodeJS engine now runs in 32 bit mode. This is required to keep compatibility with ActiveXObject support that is an essential part of WScript but has to be emulated in NodeJS.

  2. Rapise has own copy of node.exe installed. So if you have npm modules installed globally and need to use them in your test, you have to install them locally into the framework.

Npm Console

This section assumes your testing framework is running with NodeJS enabled (which is the case unless you are using an older testing framework).

You can integrate external NPM modules and packages into your test scripts. However, when using an external package, be sure to install it using Rapise's built-in package manager. Installing via a global package manager (if available) makes the packages visible to global scripts but not within Rapise tests. Instead, use the internal npm console provided by Rapise, which is tied to the NodeJS instance running your tests.

To access the internal npm console, go to the Tools > Npm Console menu.

After opening the console, you can install any package as usual.

You have the option to save the installed packages alongside your tests, or simply save the package.json or package_lock.json files and restore the dependencies when needed.

function _NpmInit()
{
    // Restore packages if necessary.
    // This assumes that the framework root folder contains a package.json file.
    if (!File.FolderExists(g_workDir + '\\node_modules'))
    {
        const npmCmd = g_helper.ResolvePath("InstrumentJS/npm.cmd");
        Global.DoCmd('"' + npmCmd + '"' + " install --prefix \"" + g_workDir + "\"", g_workDir, true, false);
    }
}

For example, you may call _NpmInit from SeSOnTestInit() function.

Reference

The language reference covers EcmaScript v2 supported by default JScript Engine. It is missing majority of latest features, properties and methods. For example, there is no Array.join or String.trim.

  • Feature Information
  • Microsoft JScript Features - ECMA
  • Microsoft JScript Features - Non-ECMA
  • Errors
  • Functions
  • Methods A-C

    Methods D-F

    Methods G

    Methods I-M

    Methods P-R

    Methods S

    Methods T-V

    Objects

    Operators

    Properties

    Statements

    JScript Fundamentals

    Advanced JScript

    Introduction to Regular Expressions

    See Also