Uh oh!
There was an error while loading. Please reload this page.
test: Remove conditional-expect anti-patterns in 3 test files - #2525
Merged
Conversation
Replace `if (!r.ok) { expect(...) }` and `if (result.ok) { return }` guards
with unconditional assertions using toThrow() or toMatchObject(). These
conditional blocks silently skipped assertions when the condition evaluated
the wrong way, providing false confidence. Also remove now-unused tryCatch
imports from prompt-file-security.test.ts and security.test.ts.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>louisgv
approved these changes
Mar 12, 2026
louisgv
left a comment
Collaborator
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: 51ba314
Findings
No security issues found. This PR refactors test files to remove conditional-expect anti-patterns by:
- Replacing
tryCatch+ conditional narrowing with directexpect().toThrow()assertions - Using
toMatchObjectinstead of manual type checking
Changes are isolated to test files only, no production code affected.
Tests
- bash -n: N/A (no shell scripts)
- bun test: PASS (150 tests across 3 files)
- biome lint: PASS (0 issues)
- curl|bash: N/A
- macOS compat: N/A
-- security/pr-reviewer
Uh oh!
There was an error while loading. Please reload this page.
AhmedTMM pushed a commit
to AhmedTMM/spawn
that referenced
this pull request
Mar 12, 2026
…RouterLabs#2525) Replace `if (!r.ok) { expect(...) }` and `if (result.ok) { return }` guards with unconditional assertions using toThrow() or toMatchObject(). These conditional blocks silently skipped assertions when the condition evaluated the wrong way, providing false confidence. Also remove now-unused tryCatch imports from prompt-file-security.test.ts and security.test.ts. Co-authored-by: spawn-qa-bot <qa@openrouter.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
AhmedTMM pushed a commit
to AhmedTMM/spawn
that referenced
this pull request
Mar 13, 2026
…RouterLabs#2525) Replace `if (!r.ok) { expect(...) }` and `if (result.ok) { return }` guards with unconditional assertions using toThrow() or toMatchObject(). These conditional blocks silently skipped assertions when the condition evaluated the wrong way, providing false confidence. Also remove now-unused tryCatch imports from prompt-file-security.test.ts and security.test.ts. Co-authored-by: spawn-qa-bot <qa@openrouter.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
5 tasks
AhmedTMM pushed a commit
to AhmedTMM/spawn
that referenced
this pull request
Mar 13, 2026
…RouterLabs#2525) Replace `if (!r.ok) { expect(...) }` and `if (result.ok) { return }` guards with unconditional assertions using toThrow() or toMatchObject(). These conditional blocks silently skipped assertions when the condition evaluated the wrong way, providing false confidence. Also remove now-unused tryCatch imports from prompt-file-security.test.ts and security.test.ts. Co-authored-by: spawn-qa-bot <qa@openrouter.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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 freeto 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
if (!r.ok) { expect(...) }andif (result.ok) { return }type-narrowing guards with unconditionaltoThrow()ortoMatchObject()assertions insecurity.test.ts,prompt-file-security.test.ts, andwith-retry-result.test.tstryCatchimports from both files after the refactorTest plan
bun testpasses: 1396 pass, 0 failbunx @biomejs/biome checkpasses on modified files with 0 errors-- qa/dedup-scanner