-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
Copy pathreact-version.test.ts
63 lines (52 loc) · 2.04 KB
/
react-version.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
53
54
55
56
57
58
59
60
61
62
63
import { nextTestSetup } from 'e2e-utils'
describe('react version', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should use react-server condition for app router server components pages', async () => {
const rscPagesRoutes = ['/app/server', '/app/server-edge']
for (const route of rscPagesRoutes) {
const $ = await next.render$(route)
expect($('#react-export-condition').text()).toBe('react-server')
expect($('#react-dom-export-condition').text()).toBe('react-server')
}
})
it('should use react-server condition for app router client components pages', async () => {
const rscPagesRoutes = ['/app/client', '/app/client-edge']
for (const route of rscPagesRoutes) {
const $ = await next.render$(route)
expect($('#react-export-condition').text()).toBe('default')
expect($('#react-dom-export-condition').text()).toBe('default')
}
})
it('should use react-server condition for app router custom routes', async () => {
const customRoutes = ['/app/route', '/app/route-edge']
for (const route of customRoutes) {
const res = await next.fetch(route)
const json = await res.json()
expect(json.react).toBe('react-server')
expect(json.reactDom).toBe('react-server')
}
})
it('should use default react condition for pages router pages', async () => {
const pagesRoutes = ['/pages-ssr', '/pages-ssr-edge']
for (const route of pagesRoutes) {
const $ = await next.render$(route)
expect($('#react-export-condition').text()).toBe('default')
expect($('#react-dom-export-condition').text()).toBe('default')
}
})
it('should use default react condition for pages router apis', async () => {
const pagesRoutes = [
'/api/pages-api',
'/api/pages-api-edge',
'/api/pages-api-edge-url-dep',
]
for (const route of pagesRoutes) {
const res = await next.fetch(route)
const json = await res.json()
expect(json.react).toBe('default')
expect(json.reactDom).toBe('default')
}
})
})