33 *
44 * These tests require:
55 * - ffmpeg installed and in PATH
6- * - Network access (for real HLS streams)
6+ * - Network access (for HLS streams)
77 * - Temp directory for output files
88 *
99 * Run with: npm run test:integration
@@ -15,16 +15,15 @@ import { join } from "node:path";
1515import { afterAll , beforeAll , describe , expect , it } from "vitest" ;
1616import { checkFfmpeg , downloadHLSVideo , fetchHLSQualities } from "./hlsDownloader.js" ;
1717
18- // Test fixtures - public HLS streams for testing
18+ // Test fixtures - HLS streams for testing
1919const TEST_STREAMS = {
20- // Apple's bipbop master playlist (for quality detection)
20+ // Our own tiny test stream hosted on GitHub Pages (~40KB, 4 seconds)
21+ local : "https://sebastian-software.github.io/offcourse/test-stream/playlist.m3u8" ,
22+ // Apple's bipbop master playlist (for quality detection, has multiple qualities)
2123 bipbopMaster :
2224 "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8" ,
2325} ;
2426
25- // Full download tests are slow - skip in CI unless explicitly enabled
26- const RUN_SLOW_TESTS = process . env . INTEGRATION_SLOW === "true" ;
27-
2827describe ( "HLS Downloader Integration" , ( ) => {
2928 let tempDir : string ;
3029
@@ -84,29 +83,25 @@ describe("HLS Downloader Integration", () => {
8483 expect ( result . errorCode ) . toBeDefined ( ) ;
8584 } , 15000 ) ;
8685
87- // Full download test - only run when INTEGRATION_SLOW=true
88- it . skipIf ( ! RUN_SLOW_TESTS ) (
89- "should download complete HLS stream (slow, set INTEGRATION_SLOW=true)" ,
90- async ( ) => {
91- const outputPath = join ( tempDir , "test-video.mp4" ) ;
92-
93- const progressUpdates : number [ ] = [ ] ;
94- const result = await downloadHLSVideo ( TEST_STREAMS . bipbopMaster , outputPath , ( progress ) => {
95- progressUpdates . push ( progress . percent ) ;
96- } ) ;
97-
98- expect ( result . success ) . toBe ( true ) ;
99- expect ( result . outputPath ) . toBe ( outputPath ) ;
100- expect ( existsSync ( outputPath ) ) . toBe ( true ) ;
101-
102- // Check file size is reasonable
103- const stats = statSync ( outputPath ) ;
104- expect ( stats . size ) . toBeGreaterThan ( 100 * 1024 ) ;
105-
106- // Should have received progress updates
107- expect ( progressUpdates . length ) . toBeGreaterThan ( 0 ) ;
108- } ,
109- 300000 // 5 minute timeout
110- ) ;
86+ // Download test using our tiny hosted test stream (~40KB, 4 seconds)
87+ it ( "should download our test HLS stream" , async ( ) => {
88+ const outputPath = join ( tempDir , "test-video.mp4" ) ;
89+
90+ const progressUpdates : number [ ] = [ ] ;
91+ const result = await downloadHLSVideo ( TEST_STREAMS . local , outputPath , ( progress ) => {
92+ progressUpdates . push ( progress . percent ) ;
93+ } ) ;
94+
95+ expect ( result . success ) . toBe ( true ) ;
96+ expect ( result . outputPath ) . toBe ( outputPath ) ;
97+ expect ( existsSync ( outputPath ) ) . toBe ( true ) ;
98+
99+ // Check file size is reasonable (our test stream is ~40KB)
100+ const stats = statSync ( outputPath ) ;
101+ expect ( stats . size ) . toBeGreaterThan ( 10 * 1024 ) ;
102+
103+ // Should have received progress updates
104+ expect ( progressUpdates . length ) . toBeGreaterThan ( 0 ) ;
105+ } , 30000 ) ; // 30 second timeout should be plenty for ~40KB
111106 } ) ;
112107} ) ;
0 commit comments