diff --git a/test/lib/next-test-utils.js b/test/lib/next-test-utils.js index 75a58ff5c69e3..91556904cf845 100644 --- a/test/lib/next-test-utils.js +++ b/test/lib/next-test-utils.js @@ -682,13 +682,15 @@ export async function getRedboxHeader(browser) { return retry( () => { if (shouldRunTurboDevTest()) { - const portal = [].slice - .call(document.querySelectorAll('nextjs-portal')) - .find((p) => - p.shadowRoot.querySelector('[data-nextjs-turbo-dialog-body]') - ) - const root = portal.shadowRoot - return root.querySelector('[data-nextjs-turbo-dialog-body]').innerText + return evaluate(browser, () => { + const portal = [].slice + .call(document.querySelectorAll('nextjs-portal')) + .find((p) => + p.shadowRoot.querySelector('[data-nextjs-turbo-dialog-body]') + ) + const root = portal.shadowRoot + return root.querySelector('[data-nextjs-turbo-dialog-body]').innerText + }) } else { return evaluate(browser, () => { const portal = [].slice