From 12e6d1d31aae5eebcea082a84027ddc0c634e28f Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 11 May 2022 11:09:53 -0700 Subject: [PATCH] test: Fix custom asset and external tests (#4215) Custom asset and external tests (not run by default) were failing to run due to missing dependencies. This fixes that issue. This also improves logging of debug info when a custom asset test times out. Related to investigation of #4161 --- karma.conf.js | 4 ++++ test/player_external.js | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index 7d7f315a0c..529a6a0a7b 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -363,6 +363,8 @@ module.exports = (config) => { // If testing custom assets, we don't serve other unit or integration tests. // External asset tests are the basis for custom asset testing, so this file // is automatically included. + clientArgs.testFiles.push('demo/common/asset.js'); + clientArgs.testFiles.push('demo/common/assets.js'); clientArgs.testFiles.push('test/player_external.js'); } else { // In a normal test run, we serve unit tests. @@ -374,6 +376,8 @@ module.exports = (config) => { } if (settings.external) { // If --external is present, we serve external asset tests. + clientArgs.testFiles.push('demo/common/asset.js'); + clientArgs.testFiles.push('demo/common/assets.js'); clientArgs.testFiles.push('test/**/*_external.js'); } } diff --git a/test/player_external.js b/test/player_external.js index 1d2500fc4e..22e80bd752 100644 --- a/test/player_external.js +++ b/test/player_external.js @@ -114,7 +114,13 @@ describe('Player', () => { const networkingEngine = player.getNetworkingEngine(); asset.applyFilters(networkingEngine); - await player.load(asset.manifestUri); + // Rather than awaiting the load() method, catch any load() errors and + // wait on the 'canplay' event. This has the advantage that we will + // get better logging of the media state on a timeout, since that + // capabilitiy is built into the waiter for media element events. + player.load(asset.manifestUri).catch(fail); + await waiter.timeoutAfter(60).waitForEvent(video, 'canplay'); + if (asset.features) { const isLive = asset.features.includes(Feature.LIVE); expect(player.isLive()).toBe(isLive);