File tree Expand file tree Collapse file tree 2 files changed +25
-21
lines changed Expand file tree Collapse file tree 2 files changed +25
-21
lines changed Original file line number Diff line number Diff line change 1717 uses : actions/setup-node@v1 
1818 with :
1919 node-version : ${{ matrix.node-version }} 
20-  - run : npm ci 
21-  - run : cp .env.example .env 
22-  - run : npm run test 
20+ 
21+  - name : Build the app 
22+  run : | 
23+  npm ci 
24+  cp .env.example .env 
25+  npm run build 
26+ 
27+   - name : Start the application 
28+  run : npm run start & 
29+ 
30+  - name : Wait for the server to start 
31+  run : sleep 5 
32+ 
33+  - name : Test API endpoint 
34+  run : | 
35+  response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/docs) 
36+  if [ $response == "200" ]; then 
37+  echo "API endpoint is reachable." 
38+  exit 0 
39+  else 
40+  echo "API endpoint is not reachable." 
41+  exit 1 
42+  fi 
Original file line number Diff line number Diff line change 1- const  apiUrl  =  "http://127.0.0.1:3000/docs" ; 
2- const  spawn  =  require ( "child_process" ) . spawn ; 
3- 
4- jest . setTimeout ( 10000 ) ; 
5- 
6- beforeAll ( async  ( )  =>  { 
7-  const  server  =  spawn ( "npm" ,  [ "run" ,  "start:dev" ] ,  {  detached : true  } ) ; 
8-  await  new  Promise ( ( resolve )  =>  setTimeout ( resolve ,  5000 ) ) ; 
9-  global . server  =  server ; 
10- } ) ; 
11- 
12- afterAll ( async  ( )  =>  { 
13-  process . kill ( - global . server . pid ) ; 
14- } ) ; 
15- 
16- test ( "API should be running and return status 200" ,  async  ( )  =>  { 
17-  const  response  =  await  fetch ( apiUrl ) ; 
18-  expect ( response . status ) . toBe ( 200 ) ; 
1+ test ( "Example testing" ,  async  ( )  =>  { 
2+  expect ( true ) . toBe ( true ) ; 
193} ) ; 
                                 You can’t perform that action at this time. 
               
                  
0 commit comments