diff --git a/src/browser/fixture.js b/src/browser/fixture.js index 3904edbd..e4c29292 100644 --- a/src/browser/fixture.js +++ b/src/browser/fixture.js @@ -31,15 +31,17 @@ function getComposedChildren(node) { async function waitForElem(elem, awaitLoadingComplete = true) { + if (!elem) return; + const doWait = async() => { - const update = elem?.updateComplete; + const update = elem.updateComplete; if (typeof update === 'object' && Promise.resolve(update) === update) { await update; await nextFrame(); } - if (awaitLoadingComplete && typeof elem?.getLoadingComplete === 'function') { + if (awaitLoadingComplete && typeof elem.getLoadingComplete === 'function') { await elem.getLoadingComplete(); await nextFrame(); } diff --git a/test/browser/fixture.test.js b/test/browser/fixture.test.js index 0136bc59..a4582aa9 100644 --- a/test/browser/fixture.test.js +++ b/test/browser/fixture.test.js @@ -193,6 +193,10 @@ describe('fixture', () => { } }); + it('should handle an empty fixture', async() => { + await fixture(html``); + }); + it('should wait for slow element at fixture root', async() => { const finishedPromise = fixture(`<${slowElem} id="slow">`) .then((elem) => elem.finished);