From dd173adf97c637d98e626033cae3f24836090738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Adem=20I=C5=9EIKLI?= Date: Sun, 10 Mar 2024 17:27:05 +0100 Subject: [PATCH] Fixed integration tests --- .DS_Store | Bin 0 -> 6148 bytes .github/workflows/tests.yml | 29 ++++++++++++++++++++++++++--- tests/app.test.js | 20 ++------------------ 3 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a9315925cb849eef695d93cf3088194213591985 GIT binary patch literal 6148 zcmeHK&1zFY7(J7wG**Qov`Ue3aUpag^Z|t1km3V$(@oK)k+hI_L!03C7Tky{11`FC zWnV$)N_>D~`vwJ2%a9gNTpvZMBrt6yUH8r~m#`2IyTlvst5 z$*e#R5+=hGwlKgT)Ny0Ji1_(ezdhJI(fn>+KP&QO^39@8*Spwb-XVJ#USL1W zF0^W%ujQ^;IDb91_oH%6U)i6yp-!9s7IkIl;5nXBvGhjh@hZ^T__}mV_C&6)_ozAk zvGmF6y@Fr3`8RxD_w6US2%o_|w(0IJ@9HpA%cwqI0mIk$v2)?+rFDEaC$oG#y1!zY zD(G5SOKqBZyr{2Zd2!?CsXk``qj0C1QITIf@eB8CDUF+ov5gKy2ciQP4#@W*VHHdr z=8E>y!Nwi|h;#Zh#lG|HLKTh`A ug!LJ#6yfEHb_yG}9ovp<#rIfkVJwjjF?E9ry))E%WgJ literal 0 HcmV?d00001 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 177e1a9..8e0e61e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,6 +4,9 @@ on: pull_request: branches: - master + push: + branches: + - test jobs: units: @@ -17,6 +20,26 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - run: npm ci - - run: cp .env.example .env - - run: npm run test + + - name: Build the app + run: | + npm ci + cp .env.example .env + npm run build + + - name: Start the application + run: npm run start & + + - name: Wait for the server to start + run: sleep 5 + + - name: Test API endpoint + run: | + response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/docs) + if [ $response == "200" ]; then + echo "API endpoint is reachable." + exit 0 + else + echo "API endpoint is not reachable." + exit 1 + fi diff --git a/tests/app.test.js b/tests/app.test.js index bf63120..8fef91f 100644 --- a/tests/app.test.js +++ b/tests/app.test.js @@ -1,19 +1,3 @@ -const apiUrl = "http://127.0.0.1:3000/docs"; -const spawn = require("child_process").spawn; - -jest.setTimeout(10000); - -beforeAll(async () => { - const server = spawn("npm", ["run", "start:dev"], { detached: true }); - await new Promise((resolve) => setTimeout(resolve, 5000)); - global.server = server; -}); - -afterAll(async () => { - process.kill(-global.server.pid); -}); - -test("API should be running and return status 200", async () => { - const response = await fetch(apiUrl); - expect(response.status).toBe(200); +test("Example testing", async () => { + expect(true).toBe(true); });