diff --git a/addon/src/test-support/get-page-title.ts b/addon/src/test-support/get-page-title.ts index 6918ca9..35ea1cb 100644 --- a/addon/src/test-support/get-page-title.ts +++ b/addon/src/test-support/get-page-title.ts @@ -1,7 +1,7 @@ // Testem appends progress to the title... // and there's no way to stop this at the moment -export function getPageTitle(doc: Document) { +export function getPageTitle(doc?: Document): string { // In Fastboot context we get 2 title elements if we don't remove one from app/index.html // In real world applications, it is mandatory to remove from app/index.html // We are keeping both for sake for testing browser and fastboot scenarios @@ -9,9 +9,9 @@ export function getPageTitle(doc: Document) { ...(doc || window.document).querySelectorAll('head title'), ].pop(); - return ( - element && - element instanceof HTMLTitleElement && - element.innerText.trim().replace(/^\(\d+\/\d+\)/, '') - ); + if (element instanceof HTMLTitleElement) { + return element.innerText.trim().replace(/^\(\d+\/\d+\)/, ''); + } + + return ''; }