File tree Expand file tree Collapse file tree 5 files changed +26
-20
lines changed Expand file tree Collapse file tree 5 files changed +26
-20
lines changed Original file line number Diff line number Diff line change 44 "description" : " Simple CI/CD backend testing" ,
55 "main" : " server.js" ,
66 "scripts" : {
7- "start" : " node server .js" ,
7+ "start" : " node src/start .js" ,
88 "test" : " jest --detectOpenHandles"
99 },
1010 "dependencies" : {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11const request = require ( 'supertest' ) ;
2- const app = require ( './server' ) ;
2+ const app = require ( './src/ server' ) ; // Only the app, no server listening!
33
44describe ( 'GET /' , ( ) => {
55 it ( 'responds with Hello CI/CD World!' , async ( ) => {
6- const response = await request ( app ) . get ( '/' ) ;
7- expect ( response . text ) . toBe ( 'Hello CI/CD World!' ) ;
8- expect ( response . statusCode ) . toBe ( 200 ) ;
6+ const res = await request ( app ) . get ( '/' ) ;
7+ expect ( res . text ) . toBe ( 'Hello CI/CD World!' ) ;
98 } ) ;
109} ) ;
10+ describe ( 'GET /nonexistent' , ( ) => {
11+ it ( 'responds with 404 Not Found' , async ( ) => {
12+ const res = await request ( app ) . get ( '/nonexistent' ) ;
13+ expect ( res . statusCode ) . toBe ( 404 ) ;
14+ } ) ;
15+ } ) ;
Original file line number Diff line number Diff line change 1+ const express = require ( 'express' ) ;
2+ const app = express ( ) ;
3+
4+ app . get ( '/' , ( req , res ) => {
5+ res . send ( 'Hello CI/CD World!' ) ;
6+ } ) ;
7+
8+ module . exports = app ;
Original file line number Diff line number Diff line change 1+ const app = require ( './server' ) ;
2+ const port = 3000 ;
3+
4+ app . listen ( port , ( ) => {
5+ console . log ( `Server running on port ${ port } ` ) ;
6+ console . log ( `http://localhost:${ port } ` ) ;
7+ console . log ( 'Press Ctrl+C to stop the server' ) ;
8+ } ) ;
You can’t perform that action at this time.
0 commit comments