Skip to content

Commit b912320

Browse files
committed
Fixed integration tests
1 parent e088996 commit b912320

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

.github/workflows/tests.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ jobs:
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

tests/app.test.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
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
});

0 commit comments

Comments
 (0)