New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
next/script: make onLoad
concurrent rendering resilient
#40191
Changes from 2 commits
d59a1b2
546f4cc
e575a89
7ff3dd7
b4e0e64
a26e69d
9109252
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,21 +163,31 @@ const runTests = (isDev = false) => { | |
}) | ||
} | ||
|
||
if (!isDev) { | ||
it('onload fires correctly', async () => { | ||
let browser | ||
try { | ||
browser = await webdriver(appPort, '/page4') | ||
await waitFor(3000) | ||
it('onload fires correctly', async () => { | ||
let browser | ||
try { | ||
browser = await webdriver(appPort, '/page4') | ||
await waitFor(3000) | ||
Comment on lines
-166
to
+170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I move the onload test to run in both dev and production mode. |
||
|
||
const text = await browser.elementById('text').text() | ||
const text = await browser.elementById('onload-div-1').text() | ||
expect(text).toBe('aaabbbccc') | ||
|
||
expect(text).toBe('aaabbbccc') | ||
} finally { | ||
if (browser) await browser.close() | ||
} | ||
}) | ||
// Navigate to different page and back | ||
await browser.waitForElementByCss('[href="/page9"]') | ||
await browser.click('[href="/page9"]') | ||
await browser.waitForElementByCss('[href="/page4"]') | ||
await browser.click('[href="/page4"]') | ||
Comment on lines
+175
to
+179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a navigation test. This is to test that |
||
|
||
await browser.waitForElementByCss('#onload-div-1') | ||
const sameText = await browser.elementById('onload-div-1').text() | ||
// onload should only be fired once, not on sequential re-mount | ||
expect(sameText).toBe('') | ||
} finally { | ||
if (browser) await browser.close() | ||
} | ||
}) | ||
|
||
if (!isDev) { | ||
it('priority beforeInteractive with inline script', async () => { | ||
const html = await renderViaHTTP(appPort, '/page5') | ||
const $ = cheerio.load(html) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During the production mode test, Next.js will perform the eslint check. Add an eslint comment for lodash to pass the eslint.