1+ import path from 'node:path' ;
2+ import { rimrafSync } from 'rimraf' ;
13import { fetch } from '@whatwg-node/fetch' ;
24import {
35 getAvailablePort ,
@@ -7,20 +9,30 @@ import {
79} from '../../nextjs-app/__integration-tests__/utils' ;
810
911jest . setTimeout ( 33_000 ) ;
12+ const nodeMajorVersion = parseInt ( process . version . split ( '.' ) [ 0 ] . replace ( 'v' , '' ) , 10 ) ;
1013
1114describe ( 'NextJS Legacy Pages' , ( ) => {
15+ if ( nodeMajorVersion < 20 ) {
16+ it . skip ( 'skips' , ( ) => { } ) ;
17+ return ;
18+ }
1219 let port : number ;
1320 let serverProcess : Proc ;
1421 beforeAll ( async ( ) => {
22+ rimrafSync ( path . join ( __dirname , '..' , '.next' ) ) ;
1523 const signal = AbortSignal . timeout ( 30_000 ) ;
1624 port = await getAvailablePort ( ) ;
1725 serverProcess = await spawn ( 'pnpm' , [ 'dev' ] , {
1826 signal,
1927 env : { PORT : String ( port ) } ,
28+ cwd : path . join ( __dirname , '..' ) ,
2029 } ) ;
2130 await waitForAvailable ( port , { signal } ) ;
2231 } ) ;
23- afterAll ( ( ) => serverProcess . kill ( ) ) ;
32+ afterAll ( ( ) => {
33+ rimrafSync ( path . join ( __dirname , '..' , '.next' ) ) ;
34+ return serverProcess ?. kill ( ) ;
35+ } ) ;
2436
2537 it ( 'should show GraphiQL' , async ( ) => {
2638 const response = await fetch ( `http://127.0.0.1:${ port } /api/graphql` , {
@@ -29,8 +41,8 @@ describe('NextJS Legacy Pages', () => {
2941 } ,
3042 } ) ;
3143
32- expect ( response . ok ) . toBe ( true ) ;
3344 expect ( await response . text ( ) ) . toContain ( '<title>Yoga GraphiQL</title>' ) ;
45+ expect ( response . ok ) . toBe ( true ) ;
3446 } ) ;
3547
3648 it ( 'should run basic query' , async ( ) => {
@@ -46,8 +58,6 @@ describe('NextJS Legacy Pages', () => {
4658 } ) ,
4759 } ) ;
4860
49- expect ( response . ok ) . toBe ( true ) ;
50-
5161 expect ( {
5262 ...Object . fromEntries ( response . headers . entries ( ) ) ,
5363 date : null ,
@@ -60,5 +70,7 @@ describe('NextJS Legacy Pages', () => {
6070
6171 expect ( json . errors ) . toBeFalsy ( ) ;
6272 expect ( json . data ?. greetings ) . toBe ( 'This is the `greetings` field of the root `Query` type' ) ;
73+
74+ expect ( response . ok ) . toBe ( true ) ;
6375 } ) ;
6476} ) ;
0 commit comments