Unit testing JavaScript with Karma. Playwright & Puppeteer

Puppeteer

Let’s start from Puppeteer

npm install puppeteer
Downloading Chromium r818858 - 132.4 Mb [====================] 100% 0.0s
process.env.CHROME_BIN = require('puppeteer').executablePath();
npx karma start
30 01 2021 18:02:19.602:INFO [karma-server]: Karma v6.0.3 server started at http://localhost:9876/
30 01 2021 18:02:19.604:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
30 01 2021 18:02:19.609:INFO [launcher]: Starting browser Chrome
30 01 2021 18:02:31.497:INFO [Chrome 88.0.4298.0 (Mac OS 11.0.0)]: Connected on socket -gzowZLOc2OrrmCUAAAB with id 15605462
Chrome 88.0.4298.0 (Mac OS 11.0.0): Executed 2 of 2 SUCCESS (0.011 secs / 0.003 secs)
TOTAL: 2 SUCCESS
browsers: ['ChromeHeadless'],

Playwright

Playwright beside Chrome automatically install Firefox and WebKit

npm install playwrightDownloading chromium v844399 - 98.5 Mb [====================] 100% 0.0s
chromium v844399 downloaded to /Caches/ms-playwright/chromium-844399
Downloading firefox v1225 - 73.9 Mb [====================] 100% 0.0s
firefox v1225 downloaded to /Caches/ms-playwright/firefox-1225
Downloading webkit v1423 - 51.3 Mb [====================] 100% 0.0s
webkit v1423 downloaded to /Caches/ms-playwright/webkit-1423
process.env.CHROME_BIN = require('playwright').chromium.executablePath();
npm install karma-firefox-launcher
process.env.FIREFOX_BIN = require('playwright').firefox.executablePath();
...
browsers: ['Firefox'],
npx karma start
30 01 2021 19:04:40.925:INFO [karma-server]: Karma v6.0.3 server started at http://localhost:9876/
30 01 2021 19:04:40.927:INFO [launcher]: Launching browsers Firefox with concurrency unlimited
30 01 2021 19:04:40.934:INFO [launcher]: Starting browser Firefox
30 01 2021 19:04:45.139:INFO [Firefox 85.0 (Mac OS 10.16)]: Connected on socket T1vGhzXoe8dhy_yxAAAB with id 60585180
Firefox 85.0 (Mac OS 10.16): Executed 2 of 2 SUCCESS (0.001 secs / 0.002 secs)
TOTAL: 2 SUCCESS

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store