Fix CI: generate test_image.png fixture in test setup - #1
Merged
Merged
Conversation
CI failed because the image/edge-case suites depend on cli/test_image.png, which is gitignored (test*.*) and never generated. It only existed as a stale local artifact, so tests passed locally but failed on clean checkouts with 'File not found'. Create it deterministically in setup hooks.
There was a problem hiding this comment.
Pull request overview
This PR aims to fix CI failures caused by test_image.png being a gitignored, stale local artifact by generating the fixture deterministically during test setup in the CLI test suites.
Changes:
- Generate
test_image.png(100×100 PNG) inimage.test.tstest setup when missing. - Generate
test_image.pnginedge-cases.test.tsbeforeAlland addsharpas a dependency for that suite.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cli/src/__tests__/image.test.ts |
Adds setup logic to create test_image.png fixture when absent. |
cli/src/__tests__/edge-cases.test.ts |
Adds sharp-based beforeAll fixture generation for test_image.png. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
+18
| beforeAll(async () => { | ||
| // Base image copied under various names by the edge-case tests | ||
| if (!fs.existsSync(TEST_IMAGE)) { | ||
| await sharp({ | ||
| create: { width: 100, height: 100, channels: 3, background: { r: 100, g: 150, b: 200 } } | ||
| }).png().toFile(TEST_IMAGE); | ||
| } |
Comment on lines
+34
to
+39
| // Primary 100×100 opaque PNG — used across the conversion/compression suite | ||
| if (!fs.existsSync(TEST_IMAGE)) { | ||
| await sharp({ | ||
| create: { width: 100, height: 100, channels: 3, background: { r: 100, g: 150, b: 200 } } | ||
| }).png().toFile(TEST_IMAGE); | ||
| } |
document.test.ts depended on gitignored cli/test.pdf, test.txt, test.docx (same test*.* stale-artifact bug). Copy them from the committed fixtures/ dir in a beforeAll so a clean checkout has them.
Content-preservation tests convert DOCX/TXT via pandoc through the real CLI. The runner had no pandoc, so those conversions exited 1. Install it before the test step.
Root tsconfig had no exclude, so 'npm run lint' (tsc --noEmit) type-checked cli/'s test files against the wrong project (78 spurious errors). Exclude cli/dist/node_modules. Also fix the one real error: App.tsx used React.ReactNode without importing the React namespace.
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.
Problem
CI failed on every push. Root cause: the image and edge-case test suites depend on
cli/test_image.png, which is gitignored by thetest*.*rule and never generated by any setup hook. It only existed as a stale local artifact, so tests passed locally but failed on clean CI checkouts withFile not found: .../cli/test_image.png(20+ cascading failures). Node 20 showed 'Cancelled' only because matrix fail-fast killed it when Node 22 failed first.Fix
Generate
test_image.pngdeterministically in the setup hooks of both suites (matches the existing pattern for__tiny_test.png/__transparent_test.png).Verification
Removed the local
cli/test_image.pngto simulate a clean checkout, then ran the suite: 145/145 pass.