-
Notifications
You must be signed in to change notification settings - Fork 26.1k
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
Improve top level await coverage #64508
Merged
timneutkens
merged 8 commits into
canary
from
04-15-Add_additional_tests_for_top_level_await
Apr 17, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5be3d37
Add additional tests for top level await
timneutkens 5372461
Write target: ES2017 as default for tsconfig for top level await
timneutkens af05946
Update snapshots
timneutkens 261e2a7
Update
timneutkens 65d61b4
Update
timneutkens bc000ee
Update
timneutkens cb6c283
Hopefully this works
timneutkens b07e72e
Skip client component test with todo
timneutkens File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
test/e2e/async-modules-app/app/app-router/client-component/skipped-page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use client' | ||
const appValue = await Promise.resolve('hello') | ||
|
||
export default function Page() { | ||
return <p id="app-router-client-component-value">{appValue}</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const appValue = await Promise.resolve('hello') | ||
|
||
export default function Page() { | ||
return <p id="app-router-value">{appValue}</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const metadata = { | ||
title: 'Next.js', | ||
description: 'Generated by Next.js', | ||
} | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-env jest */ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('Async modules', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
it('app router server component async module', async () => { | ||
const browser = await next.browser('/app-router') | ||
expect(await browser.elementByCss('#app-router-value').text()).toBe('hello') | ||
}) | ||
|
||
// TODO: Investigate/fix issue with React loading async modules failing. | ||
// Rename app/app-router/client-component/skipped-page.tsx to app/app-router/client-component/page.tsx to run this test. | ||
it.skip('app router client component async module', async () => { | ||
const browser = await next.browser('/app-router/client') | ||
expect( | ||
await browser.elementByCss('#app-router-client-component-value').text() | ||
).toBe('hello') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {} | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* eslint-env jest */ | ||
import { nextTestSetup } from 'e2e-utils' | ||
import { check } from 'next-test-utils' | ||
|
||
describe('Async modules', () => { | ||
const { next, isNextDev: dev } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('ssr async page modules', async () => { | ||
const $ = await next.render$('/') | ||
expect($('#app-value').text()).toBe('hello') | ||
expect($('#page-value').text()).toBe('42') | ||
}) | ||
|
||
it('csr async page modules', async () => { | ||
const browser = await next.browser('/') | ||
expect(await browser.elementByCss('#app-value').text()).toBe('hello') | ||
expect(await browser.elementByCss('#page-value').text()).toBe('42') | ||
expect(await browser.elementByCss('#doc-value').text()).toBe('doc value') | ||
}) | ||
|
||
it('works on async api routes', async () => { | ||
const res = await next.fetch('/api/hello') | ||
expect(res.status).toBe(200) | ||
const result = await res.json() | ||
expect(result).toHaveProperty('value', 42) | ||
}) | ||
|
||
it('works with getServerSideProps', async () => { | ||
const browser = await next.browser('/gssp') | ||
expect(await browser.elementByCss('#gssp-value').text()).toBe('42') | ||
}) | ||
|
||
it('works with getStaticProps', async () => { | ||
const browser = await next.browser('/gsp') | ||
expect(await browser.elementByCss('#gsp-value').text()).toBe('42') | ||
}) | ||
|
||
it('can render async 404 pages', async () => { | ||
const browser = await next.browser('/dhiuhefoiahjeoij') | ||
expect(await browser.elementByCss('#content-404').text()).toBe("hi y'all") | ||
}) | ||
|
||
// TODO: investigate this test flaking | ||
it.skip('can render async AMP pages', async () => { | ||
const browser = await next.browser('/config') | ||
await check( | ||
() => browser.elementByCss('#amp-timeago').text(), | ||
'just now', | ||
true | ||
) | ||
}) | ||
;(dev ? it.skip : it)('can render async error page', async () => { | ||
const browser = await next.browser('/make-error') | ||
expect(await browser.elementByCss('#content-error').text()).toBe( | ||
'hello error' | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
experimental: { | ||
amp: { | ||
validator: require.resolve('./amp-validator-wasm.js'), | ||
}, | ||
}, | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we drop this file?
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.
We could but most tests have one so it shouldn't matter much 👍