Skip to content

feat(config): enforce 100% test coverage threshold#5

Closed
JasonSooter wants to merge 1 commit into
mainfrom
feat/enforce-100-percent-test-coverage
Closed

feat(config): enforce 100% test coverage threshold#5
JasonSooter wants to merge 1 commit into
mainfrom
feat/enforce-100-percent-test-coverage

Conversation

@JasonSooter

Copy link
Copy Markdown
Contributor

Summary

  • Configures Jest coverageThreshold to require 100% across all metrics (statements, branches, functions, lines)
  • Adds prettier --write to lint-staged so formatting is enforced on every commit
  • Adds tests for fetch error handling and HTTP status code retry paths
  • Simplifies module export guard for full branch coverage
  • No functional code changes

Test plan

  • npm test passes with 100% coverage enforced
  • Verify CI runs the test suite and would block on coverage drops

🤖 Generated with Claude Code

…o pre-commit

Configures coverageThreshold to require 100% across all metrics
(statements, branches, functions, lines). Adds prettier --write to
lint-staged so formatting is enforced on every commit. Adds tests for
error handling paths and simplifies the module export guard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 11, 2026 23:56
@JasonSooter JasonSooter deleted the feat/enforce-100-percent-test-coverage branch May 12, 2026 00:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens the project’s quality gates by enforcing 100% Jest coverage thresholds, expanding tests to cover retry/error paths, and ensuring formatting is applied on staged commits.

Changes:

  • Enforce global 100% coverage across statements/branches/functions/lines in Jest config.
  • Add/adjust tests to cover fetch error handling and 5xx/429 retry behavior, and to exercise additional Segment method calls.
  • Run Prettier on staged JS files via lint-staged.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/index.test.js Adds tests for fetch rejection and HTTP 500/429 retry errors; adjusts Segment method call assertions.
src/index.js Simplifies the “exports for testing only” guard to improve coverage.
package.json Adds prettier --write to the staged lint pipeline.
jest.config.js Enables strict global 100% coverage thresholds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.js
Comment on lines +93 to +97
if (typeof process !== 'undefined' && process.env['NODE_DEV'] === 'TEST') {
module.exports = {
onRequest
};
}
Comment thread src/index.test.js
Comment on lines +63 to +81
await expect(onRequest(baseRequest, baseSettings)).rejects.toThrow(
'Network failure'
);
});

it('should throw RetryError on 500 server error', async () => {
fetch.mockResponseOnce('', { status: 500 });

await expect(onRequest(baseRequest, baseSettings)).rejects.toThrow(
'Failed with 500'
);
});

it('should throw RetryError on 429 rate limit', async () => {
fetch.mockResponseOnce('', { status: 429 });

await expect(onRequest(baseRequest, baseSettings)).rejects.toThrow(
'Failed with 429'
);
Comment thread src/index.test.js
Comment on lines +63 to +81
await expect(onRequest(baseRequest, baseSettings)).rejects.toThrow(
'Network failure'
);
});

it('should throw RetryError on 500 server error', async () => {
fetch.mockResponseOnce('', { status: 500 });

await expect(onRequest(baseRequest, baseSettings)).rejects.toThrow(
'Failed with 500'
);
});

it('should throw RetryError on 429 rate limit', async () => {
fetch.mockResponseOnce('', { status: 429 });

await expect(onRequest(baseRequest, baseSettings)).rejects.toThrow(
'Failed with 429'
);
Comment thread src/index.test.js
Comment on lines +79 to +81
await expect(onRequest(baseRequest, baseSettings)).rejects.toThrow(
'Failed with 429'
);
Comment thread src/index.test.js
Comment on lines 54 to +57
expect(Segment.identify).toHaveBeenCalledTimes(1);
expect(Segment.track).toHaveBeenCalledTimes(1);
expect(Segment.track).toHaveBeenCalledTimes(1);
expect(Segment.track).toHaveBeenCalledTimes(1);
expect(Segment.group).toHaveBeenCalledTimes(1);
expect(Segment.page).toHaveBeenCalledTimes(1);
expect(Segment.screen).toHaveBeenCalledTimes(1);
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.

2 participants