Skip to content

Commit

Permalink
[Task] #35 refactor build to run jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Type-Style committed Jan 24, 2024
1 parent 1f34521 commit 4d11814
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,5 @@ jobs:
- uses: actions/checkout@v3
- run: npm ci
- run: npm run build:prod --if-present
- name: Start server and test server response
run: |
npm start &
sleep 5 # Wait for server to start
curl localhost:80
if [ -n "$(jobs -p)" ]; then
kill $(jobs -p) # Kill background jobs
fi
- run: npm start
- run: npm test
15 changes: 15 additions & 0 deletions src/app.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios';

describe('Server Status', () => {
it('The server is running', async () => {
var serverStatus;
try {
const response = await axios.get('http://localhost');

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
serverStatus = response.status;
} catch (error) {
console.error(error);
}

expect(serverStatus).toBe(200);
})
})

0 comments on commit 4d11814

Please sign in to comment.