Cover the remaining untested branches

Open Beginner friendly
#35 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
testing

Research direction

Start with tests/validators.test.js and the branches named in src/utils/safeRegex.js and src/validators/email.js; the issue says no source changes are needed. Add tests for unsafe patterns, a throwing regex.test(), and non-string email input, then run npm run test:coverage. Done when those branches are covered and the email validator returns the input unchanged while reporting "Invalid email format".

Written by the indexing model from the issue text.

Description

good first issue tests

Coverage is 93.8%. A few small branches have no test yet:

  • src/utils/safeRegex.js, safeRegexTest():
    • the branch that rejects an unsafe pattern ('Unsafe regex pattern detected'), e.g. /(a+)+$/
    • the catch branch, when regex.test() itself throws
  • src/validators/email.js: the transform branch for non-string values, e.g. validators.email(123) should return the value unchanged and fail as "Invalid email format", not crash

What to change

  • Add tests in tests/validators.test.js (or a new tests/safe-regex.test.js)

Done when

  • npm run test:coverage shows those lines covered
  • No changes to src/ are needed. If a test reveals a bug, note it in the PR
Dominant language
JavaScript
Stars
0
Forks
7
Avg merge
1h 17m
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aniru-dh21/snap-validate

All issues in aniru-dh21/snap-validate

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.