@@ -10,6 +10,7 @@ import {
1010 launchApp ,
1111 nextBuild ,
1212 nextStart ,
13+ fetchViaHTTP ,
1314 renderViaHTTP ,
1415} from 'next-test-utils'
1516import dynamic from './dynamic'
@@ -91,53 +92,55 @@ describe('React 18 Support', () => {
9192 } )
9293 afterAll ( async ( ) => await fs . remove ( join ( appDir , 'node_modules' ) ) )
9394
94- test ( 'prerelease version of React ' , async ( ) => {
95- const output = await getBuildOutput ( appDir )
95+ test ( 'prerelease version of react in dev ' , async ( ) => {
96+ const output = await getDevOutput ( appDir )
9697 expect ( output ) . toMatch ( USING_CREATE_ROOT )
9798 expect ( output ) . toMatch ( UNSUPPORTED_PRERELEASE )
9899 } )
99100
100- test ( 'prerelease version of React ' , async ( ) => {
101- const output = await getDevOutput ( appDir )
101+ test ( 'prerelease version of react in build ' , async ( ) => {
102+ const output = await getBuildOutput ( appDir )
102103 expect ( output ) . toMatch ( USING_CREATE_ROOT )
103104 expect ( output ) . toMatch ( UNSUPPORTED_PRERELEASE )
104105 } )
105106 } )
106107} )
107108
108- describe ( 'React 18 Basic' , ( ) => {
109- describe ( 'Basic hydration' , ( ) => {
110- let app
111- let appPort
112- beforeAll ( async ( ) => {
113- await fs . remove ( join ( appDir , '.next' ) )
114- await nextBuild ( appDir , [ appDir ] , { nodeArgs } )
115- appPort = await findPort ( )
116- app = await nextStart ( appDir , appPort , { nodeArgs } )
117- } )
118- afterAll ( async ( ) => {
119- await killApp ( app )
120- } )
121- it ( 'hydrates correctly for normal page' , async ( ) => {
122- const browser = await webdriver ( appPort , '/' )
123- expect ( await browser . eval ( 'window.didHydrate' ) ) . toBe ( true )
124- expect ( await browser . elementById ( 'react-dom-version' ) . text ( ) ) . toMatch (
125- / 1 8 /
126- )
127- } )
109+ describe ( 'React 18 basics' , ( ) => {
110+ const context = { }
111+ beforeAll ( async ( ) => {
112+ await fs . remove ( join ( appDir , '.next' ) )
113+ await nextBuild ( appDir , [ appDir ] , { nodeArgs } )
114+ context . appPort = await findPort ( )
115+ context . app = await nextStart ( appDir , context . appPort , { nodeArgs } )
116+ } )
117+ afterAll ( async ( ) => {
118+ await killApp ( context . app )
128119 } )
129120
130- describe ( 'Dynamic import' , ( ) => {
131- const context = { }
121+ it ( 'hydrates correctly for normal page' , async ( ) => {
122+ const browser = await webdriver ( context . appPort , '/' )
123+ expect ( await browser . eval ( 'window.didHydrate' ) ) . toBe ( true )
124+ expect ( await browser . elementById ( 'react-dom-version' ) . text ( ) ) . toMatch ( / 1 8 / )
125+ } )
132126
133- beforeAll ( async ( ) => {
134- context . appPort = await findPort ( )
135- context . server = await launchApp ( appDir , context . appPort , { nodeArgs } )
136- } )
137- afterAll ( async ( ) => {
138- await killApp ( context . server )
139- } )
127+ it ( 'SSG works for suspense' , async ( ) => {
128+ const res1 = await fetchViaHTTP ( context . appPort , '/suspense/thrown' )
129+ const res2 = await fetchViaHTTP ( context . appPort , '/suspense/no-thrown' )
140130
141- dynamic ( context , ( p , q ) => renderViaHTTP ( context . appPort , p , q ) )
131+ expect ( res1 . status ) . toBe ( 200 )
132+ expect ( res2 . status ) . toBe ( 200 )
133+ } )
134+ } )
135+
136+ describe ( 'Dynamic import' , ( ) => {
137+ const context = { }
138+ beforeEach ( async ( ) => {
139+ context . appPort = await findPort ( )
140+ context . server = await launchApp ( appDir , context . appPort , { nodeArgs } )
141+ } )
142+ afterEach ( async ( ) => {
143+ await killApp ( context . server )
142144 } )
145+ dynamic ( context , ( p , q ) => renderViaHTTP ( context . appPort , p , q ) )
143146} )
0 commit comments