For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

How to Run Puppeteer Tests With Jest on TestMu AI


If you write Puppeteer tests with Jest, you can run the same specs across real browsers and operating systems on TestMu AI instead of a single local machine. This gives you Jest's structured output and assertions on a browser farm, whether you target a single test or an entire suite. You connect Puppeteer to the TestMu AI cloud grid through a browserWSEndpoint in your Jest configuration, then run the suite with the standard npm run test command.

Prerequisites​


Before you run your first suite, clone the sample repository and set the credentials TestMu AI uses to authenticate your session.

Sample repo
  1. Clone the TestMu AI Puppeteer repository on your system.

  2. Install the npm dependencies.

Verified
npm install
  1. Set your TestMu AI username and access key in the environment variables. Click the Access Key button at the top-right of the Automation Dashboard to find them.

Windows

Verified
set LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
set LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

macOS/Linux

Verified
export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

Run Puppeteer Jest Tests on TestMu AI​


The sample test script searches for TestMu AI on DuckDuckGo and verifies the page title. Configure the capabilities, then run the suite with a single command.

  1. To run the Puppeteer tests using Jest on TestMu AI, make the required changes to the jest-puppeteer.config.js file.
Verified
const caps_chrome = {
browserName : 'Chrome',
browserVersion : 'latest',
'LT:Options' : {
platform : 'Windows 10',
build : 'Sample Puppeteer-Jest',
name : 'Puppeteer-jest test on Chrome',
resolution : '1366x768',
user : process.env.LT_USERNAME,
accessKey : process.env.LT_USER_KEY,
network : true
}
};

const caps_edge = {
browserName : 'MicrosoftEdge',
browserVersion : 'latest',
'LT:Options' : {
platform : 'Windows 10',
build : 'Sample Puppeteer-Jest',
name : 'Puppeteer-jest test on Edge',
resolution : '1366x768',
user : process.env.LT_USERNAME,
accessKey : process.env.LT_USER_KEY,
network : true
}
};

module.exports = {
connect : {
browserWSEndpoint : `wss://cdp.lambdatest.com/puppeteer?capabilities=${encodeURIComponent(
JSON.stringify(caps_chrome)
)}`
}
};

  1. Run the following command to execute your test.
Verified
npm run test
  1. Visit the TestMu AI Automation Dashboard to see the results of your Puppeteer Jest tests.

Continue with the guides below to configure and scale your Puppeteer runs on TestMu AI.

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles