Skip to content
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

Add unstable_cache validate test case #59828

Merged
merged 4 commits into from
Dec 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,27 @@ createNextDescribe(
await next.patchFile('app/page.tsx', origText)
}
})

it('should error properly for invalid revalidate on unstable_cache', async () => {
await next.stop().catch(() => {})
const origText = await next.readFile('app/page.tsx')

try {
await next.patchFile(
'app/page.tsx',
origText.replace('// await unstable', 'await unstable')
)
await next.start().catch(() => {})

await check(async () => {
if (isNextDev) {
await next.fetch('/')
}
return next.cliOutput
}, /Invalid revalidate value "1" on "unstable_cache async \(\)=>Date.now\(\)"/)
} finally {
await next.patchFile('app/page.tsx', origText)
}
})
}
)
3 changes: 3 additions & 0 deletions test/e2e/app-dir/app-invalid-revalidate/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { unstable_cache } from 'next/cache'
// export const revalidate = '1'

export default async function Page() {
// await fetch('https://example.vercel.sh', { next: { revalidate: '1' } })
// await unstable_cache(async () => Date.now(), [], { revalidate: '1' })()
return <p>hello world</p>
}
Loading