Skip to content

test: expand coverage for core utilities, providers, and error handling#39

Open
devhimanshuu wants to merge 2 commits into
bug0inc:mainfrom
devhimanshuu:test_coverage
Open

test: expand coverage for core utilities, providers, and error handling#39
devhimanshuu wants to merge 2 commits into
bug0inc:mainfrom
devhimanshuu:test_coverage

Conversation

@devhimanshuu

Copy link
Copy Markdown

🎯 What does this PR do?

This PR significantly improves the stability of Passmark by expanding test coverage for core components that were previously under-tested.

It successfully brings line coverage to 100% for:

  • src/errors.ts
  • src/email.ts
  • src/providers/emailsink.ts

✨ Key Changes

  • Custom Errors (src/errors.ts): Added comprehensive unit tests for all custom error classes to ensure they instantiate correctly with the appropriate machine-readable error codes.
  • Email Sink Provider (src/providers/emailsink.ts): Implemented isolated tests mocking the fetch API. This verifies successful content extraction, handles JSON parsing correctly, and properly catches edge-case errors.
  • Email Extraction (src/email.ts): Added tests for extractEmailContent using Vitest's fake timers. This allowed us to verify retry logic, timeouts, and exponential backoff behavior without slowing down the overall test suite.

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 expands Vitest coverage for Passmark’s core utilities around email handling, provider integration, and the custom error hierarchy to improve confidence and regression protection.

Changes:

  • Adds unit tests for PassmarkError and all custom error subclasses (verifying names/codes/properties).
  • Adds isolated tests for the Emailsink provider, including URL construction, JSON parsing behavior, and error cases.
  • Adds tests for extractEmailContent covering initial configuration failure, success, retry behavior, and max-retry failure using fake timers.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/tests/providers/emailsink.test.ts New tests for Emailsink provider fetch/URL behavior, parsing, and failure cases.
src/tests/errors.test.ts New tests validating custom error classes and their machine-readable codes.
src/tests/email.test.ts Extends email tests to cover extractEmailContent retry/timeout flow using fake timers.

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

Comment thread src/__tests__/email.test.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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