Open guidari opened 7 months ago
I'd love to see this include adding something like a codecov ci check on our PRs.
Related issue: Research and implement a testing strategy for types provided through @carbon/react https://github.com/carbon-design-system/carbon/issues/16361
... increase confidence in each component, not just to increase coverage
One example of this that I just ran into that we should consider:
expect(onChange).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledWith(arg1, arg2, ...);
Numerous times we've fixed bugs relating to callbacks being called multiple times or not at all. We've also had plenty of times where the contents of the callback args change unintentionally. Let's make sure we always test both.
There's probably not a way to automatically enforce this, but it's a style/practice we should adopt everywhere imo
Additionally we should look at any playwright test that is
We recently found a case were the tile avt tests were actually failing locally, but passing in CI. It seems the reason was that the tests were timing out and not producing an error in ci. Locally they would fail. We should evaluate to ensure all the tests we have pass individually locally.
@tay1orjones The timing of your comment was impeccable. @ariellalgilmore and I were investigating some flakiness on our end as you wrote this. 😹
yarn test --collectCoverage
from the rootyarn test packages/react/src/components/Tooltip/__tests__/DefinitionTooltip-test.js --collectCoverage
yarn test packages/react/src/components/Tooltip/__tests__/DefinitionTooltip-test.js --coverage --collectCoverageFrom=packages/react/src/components/Tooltip/DefinitionTooltip.tsx
/coverage
- open in finder and navigate to the .html file and open it85x
is how many times the line was hit across all the tests. This number can largely be ignored3
for effort on these issuesadding https://codewithhugo.com/jest-exclude-coverage/ as a resource. In Jest 100% coverage might not be possible because it's not a "real" browser setting. For example, when testing for overflow the tests will never pick it up. The linked guide explains how to ignore or exclude files when necessary
The goal of this workstream is to increase confidence in each component, not just to increase coverage. It’s better to have 80% coverage with high-quality tests than 100% coverage with low-quality tests.
If you want to tackle any research, just create an issue to keep your notes from the research. Would be nice to look for repos that are using that on their PRs, to take as an example.