Blog ⋅ Docs ⋅ Learning Hub ⋅ Newsletter ⋅ Certifications ⋅ YouTube
Learn how to use Karma Test Runner framework to configure and run your JavaScript automation testing scripts on the LambdaTest platform
- Pre-requisites
- Configuring LambdaTest tunnel To Run Karma Tests With LambdaTest
- Integrating Your Karma Testing Framework With LambdaTest
- Avoid Timeouts With psuedoActivityInterval
In order to perform tests with LambdaTest using Karma testing framework, you would need the below things to be already set up:
1. Global Dependencies
- Make sure to use the latest version of JavaScript.
- A Git or GitHub repository
- Download and install node.js and node package manager or npm. To install node.js with homebrew use the below command.
$ brew install node
- If you have npm already installed, you may want to upgrade it to latest version. Here the code you can run in your terminal to upgrade npm.
npm install npm@latest -g
- Install Angular CLI(Command Line Interface) with the below command.
$ npm install -g @angular/cli
2. LambdaTest Authentication Credentials
Be aware of your LambdaTest authentication credentials i.e. your LambdaTest username, access key and HubURL. You need to set them up as your environment variables. You can retrieve them from your LambdaTest automation dashboard by clicking on the key icon near the help button.
Start tunnel with command from the configure tunnel in your dashboard
this tunnel name will be needed to run the tests
- For Windows user:
set LT_USERNAME=”YOUR_USERNAME”
set LT_ACCESS_KEY=”YOUR ACCESS KEY”
set LT_TUNNEL=”TUNNEL NAME”
- For macOS/Linux user:
export LT_USERNAME=”YOUR_USERNAME”
export LT_ACCESS_KEY=”YOUR ACCESS KEY”
export LT_TUNNEL=”TUNNEL NAME”
Clone the sample project from LambdaTest GitHub repository by using the below command in your cmd/terminal.
git clone https://github.com/LambdaTest/angular-karma-sample && cd angular-karma-sample
Install the node.js dependencies and Karma CLI globally using the below command.
npm install -g karma-cli && npm install
Change Browsers & Framework For Sample Project: If you wish to add more browsers or change the framework to something other than the one used in our Sample project then you can do so by editing the browser array/ framework array in the karma.conf.js file.
To help you perform cross browser testing of your locally stored web pages, LambdaTest provides an SSH(Secure Shell) tunnel connection with the name LambdaTest tunnel. With LambdaTest tunnel, you can execute a test your local Karma tests on cloud for performing automated cross browser testing on more than 2000 browsers offered by Selenium Grid on LambdaTest. So you make sure how well your changes look, even before your customers. Curious to know more about LambdaTest tunnel?
Follow our documentation on LambdaTest tunnel to know it all. OS specific instructions to download and setup tunnel binary can be found at the following links.
Download the binary file of:
Once, the tunnel is successfully set up. You can add the below code to your capabilities for testing internal servers on your network.
tunnel: true,
To integrate Karma test runner with LambdaTest you need to set up LambdaTest authentication credentials (access key & username) as your environment variables in the karma.conf.js file.
Test Scenario: Check out this sample karma.conf.js file for integrating Karma test runner with LambdaTest. You can use the sample file to test your own automation test suite by replacing the environment variables according to your need.
After declaring the required environment variable, comes the time to execute your test using the below command.
karma start karma.conf.js
karma start karma.conf.js
If you wish to use Jenkins, then follow this documentation.
Parallel testing is one of the most in-demand feature of LambdaTest Selenium Grid. By parallel testing, you can run more than one test case, simultaneously. This means that, parallel testing would allow you to execute numerous automation test cases altogether. So you execute a single test scenario across different browsers or could run different test scenarios across the same browser but with different browser versions.
To perform parallel testing, navigate to sample project “angular-karma-sample” and run the below command.
$ ng test
Monitor and analyze your test result ont the LambdaTest Automation Dashboard.
To make sure our machines are not hold for long due to some incorrect test, we have come up with a restriction on the number of seconds that our machine is kept reserved for you. In cases, where our servers fail to retrieve a request from your local machine for more than 90 seconds, then your tests are aborted from the queue with the error message related to Timeouts.
If you wish to avoid such timeouts, you need to make use of the below parameter:
customLaunchers: { chrome: {
pseudoActivityInterval: 5000 // 5000 ms heartbeat to avoid timeouts
} }
Note: psuedoActivityInterval is presented as a default parameter with a value set to 0. Make sure to provide a value more than 0 in order to avoid the timeouts.
Check out our latest tutorials on TestNG automation testing 👇
Visit the following links to learn more about LambdaTest's features, setup and tutorials around test automation, mobile app testing, responsive testing, and manual testing.
The LambdaTest Community allows people to interact with tech enthusiasts. Connect, ask questions, and learn from tech-savvy people. Discuss best practises in web development, testing, and DevOps with professionals from across the globe 🌎
To stay updated with the latest features and product add-ons, visit Changelog
LambdaTest is a leading test execution and orchestration platform that is fast, reliable, scalable, and secure. It allows users to run both manual and automated testing of web and mobile apps across 3000+ different browsers, operating systems, and real device combinations. Using LambdaTest, businesses can ensure quicker developer feedback and hence achieve faster go to market. Over 500 enterprises and 1 Million + users across 130+ countries rely on LambdaTest for their testing needs.
- Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments.
- Real-time cross browser testing on 3000+ environments.
- Test on Real device cloud
- Blazing fast test automation with HyperExecute
- Accelerate testing, shorten job times and get faster feedback on code changes with Test At Scale.
- Smart Visual Regression Testing on cloud
- 120+ third-party integrations with your favorite tool for CI/CD, Project Management, Codeless Automation, and more.
- Automated Screenshot testing across multiple browsers in a single click.
- Local testing of web and mobile apps.
- Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems.
- Geolocation testing of web and mobile apps across 53+ countries.
- LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports
- Got a query? we are available 24x7 to help. Contact Us
- For more info, visit - LambdaTest