Skip to main content

npm Plugin For TestCafe Integration With LambdaTest


TestCafe offers a comprehensive and extensive platform to perform end-to-end tests for node.js applications. It supports both JavaScript and Typescript so that you can write tests in either one of the two. With TestCafe, you can create stable tests that are easy to integrate with your continuous integration process. You can also execute multiple test cases in parallel.

LambdaTest, a cloud-based, cross browser testing platform, is out with an npm plugin that would allow you to integrate TestCafe with your LambdaTest account. That way, you can expand your test coverage using LambdaTest Selenium Grid on 2000+ real browsers and browser versions running across various operating systems for mobile, desktop, and tablets. Similar to TestCafe, LambdaTest Selenium Grid also allows you to perform parallel testing.

Prerequisites#


Important: Visit LambdaTest npm package for TestCafe.

  • Make sure you have your TestCafe Credentials.

    • For Linux/Mac:

      $ export LT_USERNAME= {YOUR_LAMBDATEST_USERNAME}$ export LT_ACCESS_KEY= {YOUR_LAMBDATEST_ACCESS_KEY}
    • For Windows:

      $ set LT_USERNAME= {YOUR_LAMBDATEST_USERNAME}$ set LT_ACCESS_KEY= {YOUR_LAMBDATEST_ACCESS_KEY}

Install LambdaTest npm Plugin For TestCafe#


Use the below command for installing the npm plugin to integrate LambdaTest with TestCafe.

npm install testcafe-browser-provider-lambdatest

How To Use npm Plugin For LambdaTest & TestCafe Integration?#


To acknowledge all available browsers aliases offered by LambdaTest Selenium Grid, type the below command:

testcafe -b lambdatest

To execute the test from cmd/terminal by declaring the browsers and operating systems to test:

$ testcafe "lambdatest:[email protected]:Windows 8" 'path/to/test/file.js'

For Parallel testing:

$ testcafe "lambdatest:[email protected]:Windows 8","lambdatest:[email protected]:Windows 10" "path/to/test/file.js"

If you are using API, then you need to declare the aliases inside your browser() method:

testCafe    .createRunner()    .src('path/to/test/file.js')    .browsers('lambdatest:[email protected]:Windows 8')    .run();

Additional Configuration Parameters#


Note: TestCafe integration with LambdaTest does not support Geolocation testing.

In case you wish to make some additional configurations to your automation test scripts, then you can incorporate the below variables:

VARIABLEDESCRIPTION
LT_TEST_NAMETo specify a name to your test on LambdaTest Selenium Grid.
LT_BUILDTo specify a name to your build on LambdaTest Selenium Grid.
LT_CAPABILITY_PATHTo specify the path of a JSON file that declares additional Desired Capabilities.
"[email protected]:Windows 8.1" : {
"network" : true,
"visual" : true,
"timezone" : "UTC+11:00"
}
Here, [email protected]:Windows 8.1 represents browser alias.
LT_RESOLUTIONTo perform cross browser testing on a specific screen resolution in the ${width}x${height} format.
LT_LOGFILEPresents detailed logs of your automation script execution. Provide a specific path to this file. If you won’t provide a path, then the logs would be saved in your present working directory by the filename: tunnel.log.
LT_VERBOSESet flag for verbose to either true or false.
LT_PROXY_HOSTA mandatory variable if you wish to perform cross browser testing through proxy. This variable is where you need to declare the hostname/IP of proxy.
LT_PROXY_PORTPort of the proxy. Default value for proxy port would be 3128.
LT_PROXY_USERUsername for connecting to proxy, mandatory value for using ‘proxypass’.
LT_PROXY_PASSPassword for the USERNAME option.
LT_TUNNEL_NAMEHuman readable tunnel identifier (Name of the tunnel)..
LT_DIRPath of the local folder you want to test.
LT_SELENIUM_VERSIONBrowser specific capability.
LT_CONSOLESet flag as true or false.
LT_NETWORKSet flag as true or false.
LT_VIDEOSet flag as true or false.
LT_SCREENSHOTSet flag as true or false.
LT_TIMEZONEConfigure tests to run on a custom time zone.

Example#


export LT_RESOLUTION="1920x1080"export LT_TEST_NAME="Test TestCafe"export LT_BUILD="Build x"testcafe "lambdatest:Chrome","lambdatest:[email protected]:Windows 8" tests/
Last updated on