fix: repair four pre-existing failing test suites#65
Merged
Conversation
- install babel-plugin-transform-import-meta; replace plugin-syntax-import-meta
so import.meta.url in generate-carousel.js is transformed for CJS/Jest
- guard the typeof import.meta check using typeof require === 'undefined'
so the ESM branch is invisible to Babel and avoids a runtime SyntaxError
- add jest.mock('puppeteer') so CarouselGenerator.init() dynamic import
is properly intercepted; update init test assertion accordingly
- update CarouselGenerator seekAndExtractFrame: null-guard screenshot
result before accessing .length; fix unused catch bindings (catch {} style)
- align test expectations with current source: thumbnailPath vs thumbnailUrl,
slide-cta.png filename, goto two-arg call, non-blank error message
- rewrite stale seekAndExtractFrame tests to exercise real source paths:
null-screenshot retry and video-element-not-found error
- migrate transcript-caption.test.js to tests/integration/ (real file I/O)
- add fixture transcript.json for regression tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
….tsx; add babelrc EOF newline SegmentPlayer.tsx: lint-staged eslint --fix auto-removed two dead eslint-disable-next-line comments but left whitespace-only replacement lines. Remove those lines entirely. .babelrc: the babel-plugin-transform-import-meta addition dropped the trailing newline; restore it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…etup tests/setup.js created and deleted a test-output/ directory in beforeAll/afterAll. No test file ever reads or writes to that directory, so the setup was dead infrastructure. In parallel Jest execution it caused a race: one suite's afterAll would delete the directory while another suite's beforeAll was still running, causing ENOENT failures non-deterministically across the edit-transcript.test.js suite. 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 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.
Fix pre-existing failing test suites
Background
Four test suites were failing before this branch was created. All four cover live production features. This PR fixes each one, migrates the misplaced integration test to the correct location per
TESTING_STANDARDS.md, and resolves two related test-infrastructure issues found during review.What was broken and why
CaptionExtractor.test.jsThe suite failed to run due to a stale mock path for the
youtube-transcriptmodule. Updated the mock target and restructured thebeforeEachsetup so the HTML-parsing fallback path is exercised by default.generate-carousel.test.js—import.metaSyntaxErrorgenerate-carousel.jsusesimport.meta.urlto detect whether it is the CLI entry point. Babel's@babel/plugin-syntax-import-metaonly parsesimport.meta— it leaves it in the CJS output, so Node throwsSyntaxError: Cannot use 'import.meta' outside a moduleat test time.babel-plugin-transform-import-meta, which rewritesimport.meta.urltorequire('url').pathToFileURL(__filename).generate-carousel.jsfromtypeof import.meta !== 'undefined'(un-transformable) totypeof require === 'undefined'so the guard short-circuits at runtime in CJS/Jest before the right-hand side is evaluated.CarouselGenerator.test.js— six failures from source/test driftThe source was refactored (switched from
puppeteer-extrato plainpuppeteer, simplified frame-extraction logic, added options topage.goto) but the tests were not updated.init—mockBrowser.launchnot a functioninit()callsawait import('puppeteer')but onlypuppeteer-extrawas mockedjest.mock('puppeteer'); setlaunchviajest.requireMockinbeforeEachgenerateCtaSlide—fetchnot calledthumbnailPathviafs.readFile, not from a URL viafetchthumbnailPath/fs.readFilegotoassertion failspage.goto(url, { waitUntil: 'load', timeout: 60000 })toHaveBeenCalledWith(stringContaining(...), expect.any(Object))seekAndExtractFramenull crashscreenshot()returningnullhitelementShot.lengthbefore the retrycontinueCarouselGenerator.js; retries correctly'Could not extract video frame'; source throws'Could not extract a non-blank video frame'hasErrorElementslogic removed from sourcetranscript-caption.test.js— wrong locationThe test reads
public/transcribe/output/transcript.jsonfrom disk — real I/O. PerTESTING_STANDARDS.md, tests with real file I/O belong intests/integration/, not next to source files. Moved and added the fixturetranscript.jsonit depends on.tests/setup.js— parallel-Jest ENOENT raceThe shared Jest setup had
beforeAll/afterAllhooks that created and deleted atest-output/directory. No test file ever read or wrote to that directory. Under parallel Jest execution this caused a non-deterministic race: one suite'safterAllwould delete the directory while another suite'sbeforeAllwas still creating it, producing intermittent ENOENT failures inedit-transcript.test.js. Removed the dead infrastructure entirely.Files changed
.babelrcbabel-plugin-transform-import-metatransform plugin; restore trailing newlinepackage.json/package-lock.jsonbabel-plugin-transform-import-metadev dependencyscripts/carousel/generate-carousel.jstypeof import.metaguard withtypeof require === 'undefined'scripts/carousel/CarouselGenerator.jsscreenshot()result; fix unusedcatchbindingsscripts/__tests__/CaptionExtractor.test.jsbeforeEachscripts/__tests__/CarouselGenerator.test.jsscripts/__tests__/generate-carousel.test.jstests/integration/transcript-caption.test.jsscripts/transcript-caption.test.jstests/setup.jstest-output/lifecycle that caused parallel-Jest ENOENT racepublic/transcribe/output/transcript.jsonremotion/Root.tsxeslint-disablecomment relocated closer to usage (cosmetic, ESLint-clean)remotion/components/SegmentPlayer.tsxeslint-disable-next-line no-consolecomments removed; whitespace-only replacement lines cleaned up (ESLint-clean)Test plan
npm test— all 230 tests across all suites pass (2 pre-existing skips)npx tsc --noEmit— no type errorsnpx eslint --max-warnings=0on changed files — clean--findRelatedTestswithout errorsIssues
Closes #64