clipwright/dashboard/e2e/fixtures/global-setup.js
pedro-bento 0040aa49da
All checks were successful
CI / dashboard-e2e (push) Successful in 1m44s
CI / unit (push) Successful in 29s
CI / backend-e2e (push) Successful in 1m17s
test/e2e-coverage (#5)
Reviewed-on: #5
Co-authored-by: pedro-bento <mail@pbento.pt>
Co-committed-by: pedro-bento <mail@pbento.pt>
2026-10-04 22:28:46 +01:00

26 lines
1.1 KiB
JavaScript

// Builds the tiny media the specs upload. ffmpeg is required by the plan; when
// it is absent (a bare `npm test` on a machine without it) we still write a
// non-empty placeholder so the upload path is exercised rather than skipped.
import { execFileSync } from 'node:child_process';
import fs from 'node:fs';
import { ARTIFACTS_DIR, SIXTY_MP4 } from './media.js';
export default function globalSetup() {
fs.mkdirSync(ARTIFACTS_DIR, { recursive: true });
try {
execFileSync('ffmpeg', [
'-y',
'-f', 'lavfi', '-i', 'testsrc=size=160x90:rate=30:duration=60',
'-f', 'lavfi', '-i', 'sine=frequency=440:duration=60',
'-c:v', 'libx264', '-pix_fmt', 'yuv420p',
'-c:a', 'aac', '-shortest',
SIXTY_MP4,
], { stdio: 'ignore' });
console.log(`[e2e] built ${SIXTY_MP4}`);
} catch (err) {
if (!fs.existsSync(SIXTY_MP4)) {
fs.writeFileSync(SIXTY_MP4, 'clipwright-e2e-placeholder');
}
console.warn(`[e2e] ffmpeg unavailable, wrote a placeholder media file: ${err.message}`);
}
}