Skip to content

Commit 6b56128

Browse files
authored
test: update test setup for stable after() (#2722)
* test: update test setup for stable after() * fix: don't skip canaries buld
1 parent 0a6cc37 commit 6b56128

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

tests/e2e/after.test.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
33
import { test } from '../utils/playwright-helpers.js'
44

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

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

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

28-
await page.goto(`${after.url}/after/trigger`)
31+
const response = await page.goto(`${after.url}/after/trigger`)
32+
33+
expect(response?.status(), 'Trigger should return 200').toBe(200)
2934

3035
// wait for next/after to trigger revalidation of check page
3136
await new Promise((resolve) => setTimeout(resolve, 5000))

tests/fixtures/after/app/after/trigger/page.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { revalidatePath } from 'next/cache'
2-
import { unstable_after as after, connection } from 'next/server'
2+
import { after, connection } from 'next/server'
33

44
export default async function Page() {
55
await connection()

tests/fixtures/after/next.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ const nextConfig = {
44
eslint: {
55
ignoreDuringBuilds: true,
66
},
7-
experimental: {
8-
after: true,
9-
},
107
}
118

129
module.exports = nextConfig

tests/fixtures/after/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"test": {
1616
"dependencies": {
17-
"next": ">=15.0.0"
17+
"next": ">=15.1.0"
1818
}
1919
}
2020
}

tests/utils/next-version-helpers.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export async function setNextVersionInFixture(
8585
if (
8686
operation === 'update' &&
8787
versionConstraint &&
88-
!satisfies(checkVersion, versionConstraint) &&
88+
!satisfies(checkVersion, versionConstraint, { includePrerelease: true }) &&
8989
version !== versionConstraint
9090
) {
9191
if (!silent) {

0 commit comments

Comments
 (0)