11// TODO: Remove eslint-disable-next-line no-undef the minute expect can be labelled as defined
22const { readdirSync } = require ( 'fs' ) ;
3- const axios = require ( 'axios' ) ;
43const { join } = require ( 'path' ) ;
54const portMap = require ( '../port-map.json' ) ;
65
@@ -10,6 +9,8 @@ const names = readdirSync(join(__dirname, '../apps')).filter(
109 name => ! / ( ^ | \/ ) \. [ ^ / . ] / g. test ( name ) && name !== 'nightlife-coordination-app'
1110) ;
1211
12+ const { baseUrl } = require ( './jest-utils.js' ) ;
13+
1314describe ( 'portMap' , ( ) => {
1415 it ( 'should have unique ports' , ( ) => {
1516 const ports = Object . values ( portMap ) ;
@@ -35,10 +36,11 @@ describe('Project statuses', () => {
3536
3637 for ( const name of projectNames ) {
3738 const portNum = portMap [ name ] ;
39+ const BASE_URL = baseUrl ( portNum ) ;
3840
3941 it ( `${ name } should be running on port ${ portNum } ` , async ( ) => {
4042 try {
41- const response = await axios . get ( `http://localhost: ${ portNum } ` ) ;
43+ const response = await fetch ( BASE_URL ) ;
4244
4345 // eslint-disable-next-line no-undef
4446 expect ( response . status ) . toBe ( 200 ) ;
@@ -49,9 +51,7 @@ describe('Project statuses', () => {
4951 } ) ;
5052 it ( `Pinging ${ name } should return a status code of 200 ` , async ( ) => {
5153 try {
52- const response = await axios . get (
53- `http://localhost:${ portNum } /status/ping`
54- ) ;
54+ const response = await fetch ( new URL ( '/status/ping' , BASE_URL ) ) ;
5555
5656 // eslint-disable-next-line no-undef
5757 expect ( response . status ) . toBe ( 200 ) ;
0 commit comments