88 stopApp ,
99 waitFor
1010} from 'next-test-utils'
11- import webdriver from 'next-webdriver'
1211
1312const context = { }
1413context . app = nextServer ( {
@@ -31,25 +30,20 @@ describe('On Demand Entries', () => {
3130 expect ( pageContent . includes ( 'Index Page' ) ) . toBeTruthy ( )
3231 } )
3332
34- it ( 'should compile pages with client side <Link />' , async ( ) => {
35- const browser = await webdriver ( context . appPort , '/' )
36- await browser . elementByCss ( '#about-link' ) . click ( )
37-
38- // Wait for 3 secs until the pages gets compiled
39- await waitFor ( 1000 * 3 )
40- const pageContent = await browser . elementByCss ( 'p' ) . text ( )
41-
33+ it ( 'should compile pages for JSON page requests' , async ( ) => {
34+ const pageContent = await renderViaHTTP ( context . appPort , '/_next/-/pages/about' )
4235 expect ( pageContent . includes ( 'About Page' ) ) . toBeTruthy ( )
43- await browser . close ( )
4436 } )
4537
4638 it ( 'should dispose inactive pages' , async ( ) => {
4739 const aboutPagePath = resolve ( __dirname , '../.next/bundles/pages/about.json' )
4840 expect ( existsSync ( aboutPagePath ) ) . toBeTruthy ( )
4941
50- // Wait for page to get disposed
51- await waitFor ( 1000 * 15 )
52-
53- expect ( existsSync ( aboutPagePath ) ) . toBeFalsy ( )
42+ // Wait maximum of jasmine.DEFAULT_TIMEOUT_INTERVAL checking
43+ // for disposing /about
44+ while ( true ) {
45+ await waitFor ( 1000 * 1 )
46+ if ( ! existsSync ( aboutPagePath ) ) return
47+ }
5448 } )
5549} )
0 commit comments