diff --git a/test/lib/next-test-utils.js b/test/lib/next-test-utils.js index 918fb43f23f8f3..6b7b889d4431c8 100644 --- a/test/lib/next-test-utils.js +++ b/test/lib/next-test-utils.js @@ -669,17 +669,27 @@ export async function hasRedbox(browser, expected = true) { export async function getRedboxHeader(browser) { return retry( - () => - evaluate(browser, () => { - const query = shouldRunTurboDevTest() ? '[data-nextjs-turbo-dialog-body]' : '[data-nextjs-dialog-header]' + () => { + if (shouldRunTurboDevTest()) { const portal = [].slice .call(document.querySelectorAll('nextjs-portal')) .find((p) => - p.shadowRoot.querySelector(query) + p.shadowRoot.querySelector('[data-nextjs-turbo-dialog-body]') ) const root = portal.shadowRoot - return root.querySelector(query).innerText - }), + return root.querySelector('[data-nextjs-turbo-dialog-body]').innerText + } else { + return evaluate(browser, () => { + const portal = [].slice + .call(document.querySelectorAll('nextjs-portal')) + .find((p) => + p.shadowRoot.querySelector('[data-nextjs-dialog-header]') + ) + const root = portal.shadowRoot + return root.querySelector('[data-nextjs-dialog-header]').innerText + }) + } + }, 10000, 500, 'getRedboxHeader'