/
fetch-warning.test.ts
52 lines (46 loc) · 1.76 KB
/
fetch-warning.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { check } from 'next-test-utils'
import { nextTestSetup } from 'e2e-utils'
describe('app-dir - fetch warnings', () => {
const { next, skipped } = nextTestSetup({
skipDeployment: true,
files: __dirname,
})
if (skipped) {
return
}
beforeAll(async () => {
// we don't need verbose logging (enabled by default in this Next app) for these tests to work
// we avoid enabling it since it's not currently compatible with Turbopack.
await next.stop()
await next.deleteFile('next.config.js')
await next.start()
await next.fetch('/cache-revalidate')
})
it('should log when request input is a string', async () => {
await check(() => {
return next.cliOutput.includes(
'fetch for https://next-data-api-endpoint.vercel.app/api/random?request-string on /cache-revalidate specified "cache: force-cache" and "revalidate: 3", only one should be specified'
)
? 'success'
: 'fail'
}, 'success')
})
it('should log when request input is a Request instance', async () => {
await check(() => {
return next.cliOutput.includes(
'fetch for https://next-data-api-endpoint.vercel.app/api/random?request-input-cache-override on /cache-revalidate specified "cache: force-cache" and "revalidate: 3", only one should be specified.'
)
? 'success'
: 'fail'
}, 'success')
})
it('should not log when overriding cache within the Request object', async () => {
await check(() => {
return next.cliOutput.includes(
`fetch for https://next-data-api-endpoint.vercel.app/api/random?request-input on /cache-revalidate specified "cache: default" and "revalidate: 3", only one should be specified.`
)
? 'fail'
: 'success'
}, 'success')
})
})