Review 12.4 Merged

81096[TASK] Migrate JavaScript unit test from karma to @web/test-runner

Benjamin Franzke CR +2 V +2 Nightmare +3132 −1558 updated 09/25/23, 13:01

Commit message

Use @web/test-runner which is toolset by the modern-web.dev and
open-wc.org initiatives. It is based on mocha and es-dev-server,
which allows to run our JavaScript modules natively in the browser
(without having to bundle them via rollup).

Note that compiled test files have been removed from the
source tree, since we configure es-dev-server to transpile
them on demand, allowing error output from tests to be
using original line numbers and unmangled identifiers.

The tests are executed in chrome by default (locally and CI).
They can be executed via:

  # Run once
  npm run test

  # Run tests whenever files change
  npm run watch:build
  npm run watch:test

  # Open browser with devtools and debug mode activated
  MODE=dev npm run watch:test -- --debug

Configuration is prepared to run in multiple browsers via playwright.
Example:

  # https://playwright.dev/docs/browsers#install-system-dependencies
  npx playwright install --with-deps
  BROWSERS=chrome,chromium,firefox,webkit npm run test

Commands executed:

  npm remove \
    karma \
    karma-chrome-launcher \
    karma-coverage \
    karma-jasmine \
    karma-junit-reporter \
    karma-rollup-preprocessor \
    jasmine-core \
    @types/jasmine

  npm install --save-dev \
    @web/test-runner \
    @web/test-runner-playwright \
    @web/dev-server-import-maps \
    @web/dev-server-esbuild \
    @open-wc/testing \
    sinon

  git rm -rf \
    typo3/sysext/core/Tests/JavaScript \
    typo3/sysext/backend/Tests/JavaScript

  npm run build

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
  • Verified V +2 Done
    • Benjamin Franzke +2
    • core-ci +1 CI

Issues 1

Files 47

Show 27 more files

Review log 79

  1. Benjamin Franzke uploaded patch set 1 09/20/23, 09:53

  2. core-ci voted on patch set 1 V -1 09/20/23, 10:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46867

  3. Benjamin Franzke uploaded patch set 2 V -1 09/20/23, 10:07

  4. core-ci voted on patch set 2 V +1 09/20/23, 10:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46869

  5. Benjamin Franzke marked it ready for review 09/25/23, 12:52

  6. Benjamin Franzke voted on patch set 2 V +2 CR +2 09/25/23, 12:52

  7. Benjamin Franzke marked it work in progress 09/25/23, 12:54

  8. Benjamin Franzke marked it ready for review 09/25/23, 13:01

  9. Benjamin Franzke merged patch set 3 09/25/23, 13:01