Merged test coverage reports #22635
Replies: 8 comments
-
I was again thinking about it. Instead of making this so complicated. Wouldn't it make sense to have workspace tasks? Basically something like this from project.json but on workspace.json level,: "targets": {
"whatever": {},
"foo": {}
} That way people could use for example nx:run-commands on a workspace level. |
Beta Was this translation helpful? Give feedback.
-
I'm going to flag this as related to testing tools for obvious reasons, but the overall viability of this may be a bit harder than one might imagine. Flags being passed into the executors are passed in by a per-executor basis. Executor runs are silo'd off for the most part, each instance of @nrwl/jest:jest as an example doesn't know about the other instances running when using affected or run-many. In the case of DTE, these would actually be distributed across machines, making it less feasible there too. One option that may work for something like this, would be to have your coverage root directory setup as a project. In this case, it may looks something like this:
{
"targets": {
"combine-reports": { // NOTE: This **_CANNOT_** be cache-able, since its source files are in gitignore and the hash would not change. Test could still be cacheable though.
"executor": "nx:run-commands",
"options": {
"command": "node ../tools/scripts/combine-coverage-reports"
},
"dependsOn": [{
"target": "test",
"project": "dependencies"
}],
"implicitDependencies": ["lib-a", "lib-b"]
}
}
} Workspace level targets are discussed here: #10002. You are correct in that they could also be used for a similar purpose. |
Beta Was this translation helpful? Give feedback.
-
Can you give a bit more detail about this solution? e.g. cli command to create the coverage project, content of |
Beta Was this translation helpful? Give feedback.
-
Could be more interesting can get |
Beta Was this translation helpful? Give feedback.
-
@AgentEnder workspace level targets has been landed here, can this task be implemented too? |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
Beta Was this translation helpful? Give feedback.
-
I might try giving something like this a shot: https://stackoverflow.com/a/65902458 Though unclear if should be using nyc now, I don't know the status of the istanbuljs ecosystem. Currently for coverage I run a separate script in ci that just runs jest directly as a multi project suite but it's extremely slow. |
Beta Was this translation helpful? Give feedback.
-
As we now migrated to Jest it would be pretty useful to have it. Are there any plans to integrated this? |
Beta Was this translation helpful? Give feedback.
-
Description
I'd like to have one unit test coverage report across all projects. Basically the combined version of all the reports in the coverage directory. Not sure if this can be accomplished by nx as you could have different coverage report formats in the same workspace.
Motivation
It would simplify integration with azure devops or compodoc a lot as both expect a single report.
Suggested Implementation
An optional flag could output a combined report
nx run-many --target=test --all --parallel --coverage --combine-coverage
Alternate Implementations
Nx could allow to add a post-task that runs after generating the tests. Similar to DependsOn but after running a task. This way you could do all sorts of merging, tidy up or other jobs after any task execution.
Beta Was this translation helpful? Give feedback.
All reactions