Unverified Commit b33bc2df authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update flakey next-script tests (#37663)

parent 6f698405
...@@ -2,7 +2,7 @@ import webdriver from 'next-webdriver' ...@@ -2,7 +2,7 @@ import webdriver from 'next-webdriver'
import { createNext } from 'e2e-utils' import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base' import { NextInstance } from 'test/lib/next-modes/base'
import { BrowserInterface } from 'test/lib/browsers/base' import { BrowserInterface } from 'test/lib/browsers/base'
import { waitFor } from 'next-test-utils' import { check } from 'next-test-utils'
describe('beforeInteractive', () => { describe('beforeInteractive', () => {
let next: NextInstance let next: NextInstance
...@@ -188,14 +188,13 @@ describe('experimental.nextScriptWorkers: true with required Partytown dependenc ...@@ -188,14 +188,13 @@ describe('experimental.nextScriptWorkers: true with required Partytown dependenc
expect(predefinedWorkerScripts).toBeGreaterThan(0) expect(predefinedWorkerScripts).toBeGreaterThan(0)
await waitFor(1000)
// Partytown modifes type to "text/partytown-x" after it has been executed in the web worker // Partytown modifes type to "text/partytown-x" after it has been executed in the web worker
await check(async () => {
const processedWorkerScripts = await browser.eval( const processedWorkerScripts = await browser.eval(
`document.querySelectorAll('script[type="text/partytown-x"]').length` `document.querySelectorAll('script[type="text/partytown-x"]').length`
) )
return processedWorkerScripts > 0 ? 'success' : processedWorkerScripts
expect(processedWorkerScripts).toBeGreaterThan(0) }, 'success')
} finally { } finally {
if (browser) await browser.close() if (browser) await browser.close()
} }
...@@ -249,13 +248,13 @@ describe('experimental.nextScriptWorkers: true with required Partytown dependenc ...@@ -249,13 +248,13 @@ describe('experimental.nextScriptWorkers: true with required Partytown dependenc
) )
expect(predefinedWorkerScripts).toEqual(1) expect(predefinedWorkerScripts).toEqual(1)
await waitFor(1000)
// Partytown modifes type to "text/partytown-x" after it has been executed in the web worker // Partytown modifes type to "text/partytown-x" after it has been executed in the web worker
await check(async () => {
const processedWorkerScripts = await browser.eval( const processedWorkerScripts = await browser.eval(
`document.querySelectorAll('script[type="text/partytown-x"]').length` `document.querySelectorAll('script[type="text/partytown-x"]').length`
) )
expect(processedWorkerScripts).toEqual(1) return processedWorkerScripts + ''
}, '1')
const text = await browser.elementById('text').text() const text = await browser.elementById('text').text()
expect(text).toBe('abc') expect(text).toBe('abc')
...@@ -281,13 +280,13 @@ describe('experimental.nextScriptWorkers: true with required Partytown dependenc ...@@ -281,13 +280,13 @@ describe('experimental.nextScriptWorkers: true with required Partytown dependenc
) )
expect(predefinedWorkerScripts).toEqual(1) expect(predefinedWorkerScripts).toEqual(1)
await waitFor(1000)
// Partytown modifes type to "text/partytown-x" after it has been executed in the web worker // Partytown modifes type to "text/partytown-x" after it has been executed in the web worker
await check(async () => {
const processedWorkerScripts = await browser.eval( const processedWorkerScripts = await browser.eval(
`document.querySelectorAll('script[type="text/partytown-x"]').length` `document.querySelectorAll('script[type="text/partytown-x"]').length`
) )
expect(processedWorkerScripts).toEqual(1) return processedWorkerScripts + ''
}, '1')
const text = await browser.elementById('text').text() const text = await browser.elementById('text').text()
expect(text).toBe('abcd') expect(text).toBe('abcd')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment