nest
nest copied to clipboard
test(common): improve test coverage for shared utils
trafficstars
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [x] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Other... Please describe:
What is the current behavior?
- The shared
isEmpty()utility handles multiple cases inconsistently:- Returns
truefornull,undefined, and empty arrays - Returns
falsefor all other values (objects, strings, etc.)
- Returns
- No type safety for array checks (requires manual
Array.isArrayguards) - Critical packages like
@nestjs/graphqldepend on this exact implementation
Issue Number: N/A
What is the new behavior?
New Behavior
// Original (maintained)
export function isEmpty(value: unknown): boolean;
// New (recommended)
export function isEmptyArray(value: unknown): value is unknown[];
Does this PR introduce a breaking change?
- [ ] Yes
- [x] No
Other information
Pull Request Test Coverage Report for Build c7002453-0d8f-4ba5-bb62-ae87c6b05d20
Details
- 63 of 64 (98.44%) changed or added relevant lines in 20 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+0.002%) to 89.31%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| packages/common/utils/shared.utils.ts | 23 | 24 | 95.83% |
| <!-- | Total: | 63 | 64 |
| Totals | |
|---|---|
| Change from base Build c43a5ccd-88ab-4646-8716-e80989f2dd70: | 0.002% |
| Covered Lines: | 7160 |
| Relevant Lines: | 8017 |
💛 - Coveralls
Hi @kamilmysliwiec , is there anything else needed to get this merged? Happy to help if further changes are required !
Hey @BrahimAbdelli, everything looks great! I flagged this PR as "blocked" as there're a few changes that may introduce minor breaking changes in case someone relied on these utils in community packages