-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
projects and collectCoverageFrom do not work together #9628
Comments
Moved the following config props from globalConfig to projectConfig: collectCoverageFrom, collectCoverageOnlyFrom, coverageThreshold You can now specify those properties per project. As a side effect, they were removed from the whitelist of watch-able properties.
Moved the following config props from globalConfig to projectConfig: collectCoverageFrom, collectCoverageOnlyFrom, coverageThreshold You can now specify those properties per project. As a side effect, they were removed from the whitelist of watch-able properties.
Moved the following config props from globalConfig to projectConfig: collectCoverageFrom, collectCoverageOnlyFrom, coverageThreshold You can now specify those properties per project. As a side effect, they were removed from the whitelist of watch-able properties.
Moved the following config props from globalConfig to projectConfig: collectCoverageFrom, collectCoverageOnlyFrom, coverageThreshold You can now specify those properties per project. As a side effect, they were removed from the whitelist of watch-able properties.
Added PR #9633 which implements the DRY solution described above. |
Moved the following config props from globalConfig to projectConfig: collectCoverageFrom, collectCoverageOnlyFrom, coverageThreshold You can now specify those properties per project. As a side effect, they were removed from the whitelist of watch-able properties.
Moved the following config props from globalConfig to projectConfig: collectCoverageFrom, collectCoverageOnlyFrom, coverageThreshold You can now specify those properties per project. As a side effect, they were removed from the whitelist of watch-able properties.
Moved the following config props from globalConfig to projectConfig: collectCoverageFrom, collectCoverageOnlyFrom, coverageThreshold You can now specify those properties per project. As a side effect, they were removed from the whitelist of watch-able properties.
The problem still exists, any solution? |
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075. Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](jestjs/jest#9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`. By way of example, this build system feature allows us to add fences like this: ```javascript this.store.updateStructure({ ..., GasFeeController: this.gasFeeController, TokenListController: this.tokenListController, ///: BEGIN:ONLY_INCLUDE_IN(beta) PluginController: this.pluginController, ///: END:ONLY_INCLUDE_IN }); ``` Which at build time are transformed to the following if the build type is not `beta`: ```javascript this.store.updateStructure({ ..., GasFeeController: this.gasFeeController, TokenListController: this.tokenListController, }); ``` Co-authored-by: Mark Stacey <markjstacey@gmail.com>
The solution in my case was to add the |
I'm facing the same problem too. |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
Ping |
We're hacking around this by dynamically including const selectIndex = process.argv.indexOf('--selectProjects');
const endIndex = process.argv.findIndex((arg, i) => arg.startsWith('--') && i > selectIndex);
const projects = process.argv.slice(selectIndex + 1, endIndex > -1 ? endIndex : undefined);
const coverageThresholds: Record<string, CoverageThresholdValue> = {
'apps/my-app': {
lines: 25,
statements: 25,
branches: 17,
functions: 20,
},
};
const isSelectedProject = (path: string) =>
projects.some((project) => path.split('/').includes(project));
export default {
...
coverageThresholds: {
global: {
lines: 80,
statements: 80,
branches: 70,
functions: 80,
},
...Object.entries(coverageThresholds).reduce(
(out, [path, value]) => ({ ...out, ...(isSelectedProject(path) ? { [path]: value } : {}) }),
{},
),
}
...
} |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
No stale. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
We're using using Jest's
projects
feature to run tests in all packages of a monorepo concurrently. It's blazingly fast, and especially useful in CI ❤️ .The problem is that some packages need to exclude a pattern (e.g,
/index.js
) from test coverage. Other packages need to include the same pattern in their test coverage.Specifying
collectCoverageFrom
in each package's config works when running Jest at the specific package. When running at the repo root (usingprojects
), the individualcollectCoverageFrom
props are ignored.Specifying
collectCoverageFrom
at the root config does not work: The package path is not included in the tested path/glob, and so you cannot includepackage1/index.js
while excludingpackage2/index.js
.To Reproduce
Have two packages with the same relative source filename, (e.g,
index.js
at the package root).Try to include only one package's file in coverage, while excluding the other package's file.
Expected behavior
To keep things DRY, I would prefer if
collectCoverageFrom
at the root config would be inherited from the individual project's config.Another option is specifying the project's path in
collectCoverageFrom
at the root:Link to repo
https://github.com/salto-io/jest_projects_coverage_issue
envinfo
Jest version:
25.1.0
(Also tried with
24.9
)The text was updated successfully, but these errors were encountered: