File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 287287 "package-manager-detector" : " ^1.0.0" ,
288288 "pixelmatch" : " ^7.1.0" ,
289289 "pngjs" : " ^7.0.0" ,
290+ "portfinder" : " ^1.0.37" ,
290291 "prettier" : " ^3.4.1" ,
291292 "pretty-format" : " ^29.7.0" ,
292293 "prismjs" : " ^1.29.0" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { globSync } from 'glob';
66import { createServer } from 'http-server' ;
77import fetch from 'isomorphic-fetch' ;
88import uniq from 'lodash/uniq' ;
9+ import portfinder from 'portfinder' ;
910
1011const components = uniq (
1112 globSync ( 'components/!(overview)/*.md' , { cwd : join ( process . cwd ( ) ) , dot : false } ) . map ( ( path ) =>
@@ -15,8 +16,11 @@ const components = uniq(
1516
1617describe ( 'site test' , ( ) => {
1718 let server : http . Server | https . Server ;
18- const port = 3000 ;
19+ const portPromise = portfinder . getPortPromise ( {
20+ port : 3000 ,
21+ } ) ;
1922 const render = async ( path : string ) => {
23+ const port = await portPromise ;
2024 const resp = await fetch ( `http://127.0.0.1:${ port } ${ path } ` ) . then ( async ( res ) => {
2125 const html : string = await res . text ( ) ;
2226 const $ = load ( html , { xml : true } ) ;
@@ -46,7 +50,8 @@ describe('site test', () => {
4650 expect ( tables . length ) . toMatchSnapshot ( ) ;
4751 } ;
4852
49- beforeAll ( ( ) => {
53+ beforeAll ( async ( ) => {
54+ const port = await portPromise ;
5055 server = createServer ( { root : join ( process . cwd ( ) , '_site' ) } ) ;
5156 server . listen ( port ) ;
5257
You can’t perform that action at this time.
0 commit comments