-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
271 changed files
with
1,611 additions
and
910 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/github-actions/test-results-to-slack/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
projects/github-actions/test-results-to-slack/tests/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/js-packages/ai-client/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/js-packages/analytics/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/js-packages/api/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...js-packages/babel-plugin-replace-textdomain/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
projects/js-packages/babel-plugin-replace-textdomain/tests/jest.config.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const path = require( 'path' ); | ||
const coverageConfig = require( 'jetpack-js-tools/jest/config.coverage.js' ); | ||
|
||
module.exports = { | ||
...coverageConfig, | ||
rootDir: path.join( __dirname, '..' ), | ||
}; |
5 changes: 5 additions & 0 deletions
5
projects/js-packages/boost-score-api/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const path = require( 'path' ); | ||
const coverageConfig = require( 'jetpack-js-tools/jest/config.coverage.js' ); | ||
|
||
module.exports = { | ||
...coverageConfig, | ||
rootDir: path.join( __dirname, '..' ), | ||
}; |
5 changes: 5 additions & 0 deletions
5
projects/js-packages/components/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/js-packages/config/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
// Note we intentionally don't use jetpack-js-tools/jest/config.base.js here. | ||
// This doesn't need jsdom or any of the other fancy stuff, but it does need to avoid the | ||
// standard jest-jetpack-config.js mocking. | ||
const coverageConfig = require( 'jetpack-js-tools/jest/config.coverage.js' ); | ||
|
||
module.exports = { | ||
...coverageConfig, | ||
testMatch: [ '<rootDir>/**/test/*.[jt]s' ], | ||
resolver: require.resolve( 'jetpack-js-tools/jest/jest-resolver.js' ), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/js-packages/connection/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/js-packages/critical-css-gen/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
projects/js-packages/critical-css-gen/tests/config/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import coverageConfig from 'jetpack-js-tools/jest/config.coverage.js'; | ||
|
||
export default { | ||
...coverageConfig, | ||
rootDir: '../', | ||
testEnvironment: 'jest-environment-node', | ||
testMatch: [ '**/?(*.)+(spec|test).js' ], | ||
setupFilesAfterEnv: [ './config/jest-setup.js' ], | ||
collectCoverageFrom: [ '../build-node/*.js' ], | ||
testPathIgnorePatterns: [ '/node_modules/', 'config/jest-setup.js', 'build-node/*' ], | ||
moduleDirectories: [ 'build-node', 'node_modules' ], | ||
}; |
5 changes: 5 additions & 0 deletions
5
projects/js-packages/eslint-changed/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
const path = require( 'path' ); | ||
const coverageConfig = require( 'jetpack-js-tools/jest/config.coverage.js' ); | ||
|
||
module.exports = { | ||
...coverageConfig, | ||
rootDir: path.resolve( __dirname, '..' ), | ||
roots: [ '<rootDir>/tests/' ], | ||
collectCoverageFrom: [ '<rootDir>/src/**/*.js' ], | ||
resolver: require.resolve( 'jetpack-js-tools/jest/jest-resolver.js' ), | ||
collectCoverageFrom: [ | ||
'<rootDir>/bin/**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts}', | ||
...coverageConfig.collectCoverageFrom, | ||
], | ||
}; |
5 changes: 5 additions & 0 deletions
5
projects/js-packages/eslint-config-target-es/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
projects/js-packages/eslint-config-target-es/tests/jest.config.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const path = require( 'path' ); | ||
const coverageConfig = require( 'jetpack-js-tools/jest/config.coverage.js' ); | ||
|
||
module.exports = { | ||
...coverageConfig, | ||
rootDir: path.join( __dirname, '..' ), | ||
}; |
5 changes: 5 additions & 0 deletions
5
projects/js-packages/i18n-check-webpack-plugin/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
projects/js-packages/i18n-check-webpack-plugin/tests/jest.config.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const path = require( 'path' ); | ||
const coverageConfig = require( 'jetpack-js-tools/jest/config.coverage.js' ); | ||
|
||
module.exports = { | ||
...coverageConfig, | ||
rootDir: path.join( __dirname, '..' ), | ||
}; |
5 changes: 5 additions & 0 deletions
5
...ects/js-packages/i18n-loader-webpack-plugin/changelog/update-switch-to-raw-coverage-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Generate raw phpunit and/or jest coverage data instead of clover. | ||
|
||
|
Oops, something went wrong.