Skip to content

Commit

Permalink
chore: add test and use npm workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
marianfoo committed Nov 19, 2024
1 parent 1528c3b commit 09977d9
Show file tree
Hide file tree
Showing 8 changed files with 4,473 additions and 1,963 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Jest Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Start test server
run: npm run start:test &
# Run in background and continue

- name: Wait for server to be ready
run: |
timeout=30
while ! nc -z localhost 4004; do
if [ $timeout -le 0 ]; then
echo "Timeout waiting for server to start"
exit 1
fi
timeout=$((timeout-1))
sleep 1
done
- name: Run tests
run: npm test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules/
/node_modules/
coverage/
14 changes: 14 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
testEnvironment: 'node',
testTimeout: 30000,
testMatch: [
"**/tests/**/*.test.js"
],
verbose: true,
collectCoverage: true,
coverageDirectory: "coverage",
coverageReporters: [
"text",
"lcov"
]
}
Loading

0 comments on commit 09977d9

Please sign in to comment.