Skip to content

Commit

Permalink
Add unstable_cache validate test case (vercel#59828)
Browse files Browse the repository at this point in the history
Follow-up to vercel#59822 adding an
additional test case.

Closes NEXT-1918
  • Loading branch information
ijjk authored and agustints committed Jan 6, 2024
1 parent 359f14c commit acb4025
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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/)
} 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>
}

0 comments on commit acb4025

Please sign in to comment.