feat(config): enforce 100% test coverage threshold#5
Closed
JasonSooter wants to merge 1 commit into
Closed
Conversation
…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>
There was a problem hiding this comment.
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 on lines
+93
to
+97
| if (typeof process !== 'undefined' && process.env['NODE_DEV'] === 'TEST') { | ||
| module.exports = { | ||
| onRequest | ||
| }; | ||
| } |
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 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 on lines
+79
to
+81
| await expect(onRequest(baseRequest, baseSettings)).rejects.toThrow( | ||
| 'Failed with 429' | ||
| ); |
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
coverageThresholdto require 100% across all metrics (statements, branches, functions, lines)prettier --writetolint-stagedso formatting is enforced on every commitTest plan
npm testpasses with 100% coverage enforced🤖 Generated with Claude Code