Skip to content

test: update test setup for stable after() #2722

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

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tests/e2e/after.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
import { test } from '../utils/playwright-helpers.js'

test('next/after callback is executed and finishes', async ({ page, after }) => {
test.skip(!nextVersionSatisfies('>=15.0.0'), 'This test is only for Next.js 15+')
test.skip(
!nextVersionSatisfies('>=15.1.0'),
'This test is only for Next.js >=15.1.0 that has stable after() support',
)

// trigger initial request to check page which might be stale and allow regenerating in background
await page.goto(`${after.url}/after/check`)
Expand All @@ -25,7 +28,9 @@ test('next/after callback is executed and finishes', async ({ page, after }) =>

expect(pageInfo2.timestamp, 'Check page should be cached').toBe(pageInfo1.timestamp)

await page.goto(`${after.url}/after/trigger`)
const response = await page.goto(`${after.url}/after/trigger`)

expect(response?.status(), 'Trigger should return 200').toBe(200)
Comment on lines +31 to +33
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In main this results in 50x status (due to no longer existing export) - the test failed which is good, but assertion errors didn't show much details other than things not working

This added assertion is just to have more context about potential future failures


// wait for next/after to trigger revalidation of check page
await new Promise((resolve) => setTimeout(resolve, 5000))
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/after/app/after/trigger/page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { revalidatePath } from 'next/cache'
import { unstable_after as after, connection } from 'next/server'
import { after, connection } from 'next/server'

export default async function Page() {
await connection()
Expand Down
3 changes: 0 additions & 3 deletions tests/fixtures/after/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ const nextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
experimental: {
after: true,
},
}

module.exports = nextConfig
2 changes: 1 addition & 1 deletion tests/fixtures/after/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"test": {
"dependencies": {
"next": ">=15.0.0"
"next": ">=15.1.0"
}
}
}
Loading