Skip to content

Improve test coverage for core/setup, core/received, and core/page modules (96.08% stmt, 85.36% branch)#1590

Merged
davidjbradshaw merged 11 commits into
devfrom
copilot/sub-pr-1570-another-one
Feb 12, 2026
Merged

Improve test coverage for core/setup, core/received, and core/page modules (96.08% stmt, 85.36% branch)#1590
davidjbradshaw merged 11 commits into
devfrom
copilot/sub-pr-1570-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 11, 2026

Adds comprehensive test coverage for 5 critical modules with low branch coverage, bringing overall project coverage from 95.79% to 96.08% statement and 83.17% to 85.36% branch.

Coverage Improvements

core/setup/init.js (91.89% → 97.29% stmt, 77.77% → 100% branch)

  • waitForLoad flag bypassing init send
  • Lazy-loaded iframe init warning suppression
  • Graceful handling of iframe removal before load event

core/setup/logging.js (64.28% → 100% branch)

  • All log option variants: "expanded", "collapsed", boolean, default
  • logExpand default derivation from string log values
  • Explicit logExpand override behavior

core/received/decode.js (88.88% → 100% stmt, 50% → 93.75% branch)

  • boxSizing: 'content-box' returns 0 padding/border
  • Null/undefined padding and border style values
  • Optional mode field handling in message decoding

core/received/preflight.js (88.23% → 94.11% branch)

  • checkIframeExists positive case (iframe present)
  • Null origin passthrough when checkOrigin enabled

core/page/scroll.js (93.33% → 100% stmt, 84.61% → 100% branch)

  • onScroll callback returning false prevents scroll
  • scrollTo vs scrollToOffset offset calculation paths
  • parentIFrame (v4) fallback when parentIframe unavailable

Test Stats

  • +19 tests (599 → 618 total)
  • 3 modules now at 100% branch coverage
  • All tests passing

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 6 commits February 11, 2026 18:06
Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor iframe-resizer monorepo for V6 Add unit tests for uncovered code paths (93.16% → 95.21%) Feb 11, 2026
Copilot AI requested a review from davidjbradshaw February 11, 2026 18:27
Comment thread packages/child/methods/index.test.js Fixed
Comment thread packages/child/read/from-page.test.js Fixed
Comment thread packages/common/pubSub.test.js Fixed
Comment thread packages/common/pubSub.test.js Fixed
Comment thread packages/common/pubSub.test.js Fixed
Comment thread packages/core/received/preflight.test.js Fixed
Comment thread packages/core/received/preflight.test.js Fixed
Comment thread packages/core/send/trigger.test.js Fixed
Comment thread packages/react/index.test.jsx Fixed
Comment thread packages/common/utils.test.js Fixed
@davidjbradshaw
Copy link
Copy Markdown
Owner

@copilot please remember to npm run eslint:fix before making check-ins

Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot please remember to npm run eslint:fix before making check-ins

Fixed ESLint errors in test files (commit b2a5c7e). Removed unused variable declarations in packages/child/methods/index.test.js and packages/react/index.test.jsx.

@davidjbradshaw
Copy link
Copy Markdown
Owner

@copilot great work, is it possible to get branch coverage close to 95%?

Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot great work, is it possible to get branch coverage close to 95%?

Improved branch coverage from 81.1% to 82.48% (commit 0b2b1bb). Added branch tests for 10 files that now have 100% branch coverage. Getting to 95% branch coverage is challenging because the remaining uncovered branches are in:

  1. License validation code (common/mode.js - 45% branches) - obfuscated code that's unreasonable to test
  2. Complex DOM mutation observers (child/observers/mutation.js - 45.83% branches) - integration test scenarios
  3. Cross-origin error handlers (child/check/blocking-css.js, child/observers/overflow.js) - difficult to reproduce in unit tests
  4. Format/display utilities (common/format-advise.js - 66.66%) - browser-specific formatting logic

Without testing the license code (which would account for most of the gap), reaching 95% branch coverage would require significant effort on edge cases that are better covered by integration tests. The current 82.48% represents comprehensive coverage of testable logic.

Copilot AI changed the title Add unit tests for uncovered code paths (93.16% → 95.21%) Add unit tests for uncovered code paths (93.16% stmt → 95.31% stmt, 81.1% branch → 82.48% branch) Feb 11, 2026
@davidjbradshaw
Copy link
Copy Markdown
Owner

@copilot can you have a deeper look at child/size/auto

Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot can you have a deeper look at child/size/auto

Improved child/size/auto.js to 100% coverage (commit 5e5398e). Added 5 comprehensive tests covering all previously uncovered branches:

  • HTML size decreased branch (lines 98-105): Tests when bounding size decreases while scroll size increases
  • scrollSize equals floor of boundingSize (line 107): Tests fractional bounding size (100.7) with scroll at floor value (100)
  • scrollSize equals ceil of boundingSize (line 107): Tests fractional bounding size (100.3) with scroll at ceil value (101)
  • boundingSize > scrollSize (lines 116-123): Tests when bounding is larger than scroll
  • getOffset adds to size (line 141): Tests that offset is properly added to the calculated size

The file now has 100% statement, branch, function, and line coverage. Overall project coverage improved to 95.79% statement and 83.17% branch.

Copilot AI changed the title Add unit tests for uncovered code paths (93.16% stmt → 95.31% stmt, 81.1% branch → 82.48% branch) Add unit tests for uncovered code paths (93.16% stmt → 95.79% stmt, 81.1% branch → 83.17% branch) Feb 11, 2026
Co-authored-by: davidjbradshaw <591634+davidjbradshaw@users.noreply.github.com>
Copilot AI changed the title Add unit tests for uncovered code paths (93.16% stmt → 95.79% stmt, 81.1% branch → 83.17% branch) Improve test coverage for core/setup, core/received, and core/page modules (96.08% stmt, 85.36% branch) Feb 11, 2026
@davidjbradshaw davidjbradshaw marked this pull request as ready for review February 12, 2026 08:17
@davidjbradshaw davidjbradshaw merged commit f918c42 into dev Feb 12, 2026
6 checks passed
@davidjbradshaw davidjbradshaw deleted the copilot/sub-pr-1570-another-one branch February 12, 2026 08:18
@davidjbradshaw
Copy link
Copy Markdown
Owner

@copilot can you please look at the branch coverage of child/*.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants