Support & information center

rtcRequire()

Enables you to install and use npm packages as part of your test scripts. npm is a package manager for JavaScript that makes it easy to share and reuse code. With npm support in testRTC, you can now leverage the ecosystem of packages and modules provided by the Node.js community.

rtcRequire() can be used by applications to use third party packages and enhance the capabilities of their scripts. This script command receives a package name and a function as an input. The function will operate in the context of the package.

Arguments

NameTypeDescription
namestringThe name of the package. This can also include a version number using the format <name>@<version>.
npmFunctfunction(object)The npm package can be used inside this function. Outside of it, it won’t exist.

Example

client.rtcRequire("jsonwebtoken", function(jwt) {
    var token = jwt.sign({ foo: 'bar' }, 'shhhhh');
    client.rtcInfo("Token: " + token);
});

client.rtcRequire("[email protected]", function(uuid) {
    client.rtcInfo("UUID: " + uuid());
});Code language: JavaScript (javascript)

Was this article helpful?

Related Articles