From 4770451c0bef5f48899758aa569bdd4e4a8e29a4 Mon Sep 17 00:00:00 2001 From: anomiex Date: Sat, 2 Nov 2024 12:01:38 +0000 Subject: [PATCH] coverage: Switch to raw coverage files (#40013) It turns out that there really aren't any really good generic coverage reporting tools, the best you can get is something that highlights covered lines without function/method stats, branch info, or anything else fancy. To provide useful coverage output, we're going to look instead at generating separate coverage dashboards for PHP (PHPUnit) and JS (jest/istanbul), each generated by those tools so we can get all the useful info possible. To do that, we'll need all the coverage commands to generate the tools' raw data formats rather than a lossy format like clover. As part of this conversion, we're adding `jest.config.cjs` everywhere so we can consistently set `collectCoverageFrom`. By default the base config will include non-test files under `src/`. Various packages need additional dirs such as `components/`, and a root-level `index.jsx` or `global.d.ts` seems common too. Then, since we have config files everywhere, we can move `coverageDirectory` and `coverageReporters` into the configs too. Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11642430412 Upstream-Ref: Automattic/jetpack@161c7a68f045ceb3ff8dad73ed308a9b53738c36 --- composer.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index da09de7..e79400e 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "./vendor/phpunit/phpunit/phpunit --colors=always" ], "test-coverage": [ - "php -dpcov.directory=. ./vendor/bin/phpunit --coverage-clover \"$COVERAGE_DIR/php/clover.xml\"", + "php -dpcov.directory=. ./vendor/bin/phpunit --coverage-php \"$COVERAGE_DIR/php.cov\"", "pnpm run test-coverage" ], "test-php": [ diff --git a/package.json b/package.json index e65ce6d..e6f9a54 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "validate": "pnpm exec validate-es build/", "watch": "pnpm build && pnpm build-client --watch", "test": "NODE_OPTIONS=--experimental-vm-modules jest", - "test-coverage": "pnpm run test --coverageDirectory=\"$COVERAGE_DIR/js\" --coverage --coverageReporters=clover" + "test-coverage": "pnpm run test --coverage" }, "devDependencies": { "@automattic/calypso-color-schemes": "3.1.3",