cefn / lauf

Monorepo for lauf packages.
MIT License
5 stars 0 forks source link

Playwright vs. Karma #138

Open cefn opened 3 years ago

cefn commented 3 years ago

Playwright is described in docs...

Playwright is an out-of-process automation driver
[...]
Playwright CLI will generate JavaScript code for the user interactions. codegen will attempt to generate resilient text-based selectors.

By contrast with e.g. Playwright or Webdriver-based solutions, Karma and Jasmine have a test runner which is in-process, which simplifies e.g. the creation of distinct Store configurations for component testing using logic directly within the VM, while still allowing text-based selectors through @testing-library/react.

Should document these two alternatives and their strengths, weaknesses.

A Google Doc was sketched out for this at https://docs.google.com/document/d/1syS53hhFUTmomwnpefx1DoD2DZW3MNJmmkhd1sbopm0/edit?usp=sharing

cefn commented 3 years ago

Interesting to read the comment about...

process.env.CHROME_BIN = require('playwright').chromium.executablePath();

...at https://maksimrv.medium.com/unit-testing-javascript-with-karma-playwright-puppeteer-1d54139d422 which outlines how to configure Karma to use the Chrome downloaded by Playwright, giving some level of integration or at least CI download efficiency to allow the seamless use of both strategies at once.

cefn commented 3 years ago

Also the opposite strategy is adopted in https://github.com/hugomrdias/playwright-test which is to use Playwright to launch suites to run in a browser. Unfortunately they don't support Jasmine, which might simplify the alignment with jest-like assertions. Depends how the expect dependency is made available if at all.