fix: guard __PACKAGE_VERSION__ to avoid ReferenceError in tests #225
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.
fix: guard PACKAGE_VERSION to avoid ReferenceError in tests
Summary
Fixed a
ReferenceError: __PACKAGE_VERSION__ is not definedthat was preventing e2e tests from running. Changed the version check insrc/version.tsfrom__PACKAGE_VERSION__ === undefinedtotypeof __PACKAGE_VERSION__ === 'undefined'to safely handle cases where the global constant doesn't exist (e.g., when running tests directly from TypeScript source without going through the build process).Technical details:
__PACKAGE_VERSION__is injected by tsup during builds via thedefineoptiontypeofwhich safely returns'undefined'without throwingReview & Testing Checklist for Human
pnpm run test:e2eand confirm tests execute without the ReferenceError (note: there's one flaky test inpdf-blob/index.test.tsthat fails due to OCR misreading - this is unrelated to this fix)pnpm buildand verify the built output still contains the correct package version (not '0.0.0-test')sending large pdf base64 blob with FileParserPlugintest fails intermittently because the AI model misreads "LARGE-M9N3T" as "LARGE-MNGT" or "LARGE-MN3T". Should this test be made more lenient or is this a real issue to investigate?Test Plan
pnpm typecheck- should pass ✓pnpm test- should pass ✓pnpm run test:e2e- should run without ReferenceError (may have 1 flaky test failure unrelated to this fix)pnpm buildand verify dist/index.js contains the real version numberNotes