Skip to content

Commit 7bb7e62

Browse files
committed
Add healthcheck to json_server and wait for it in test-rest
- Added Node.js-based healthcheck to json_server to verify it's ready - Updated test-rest depends_on to wait for json_server health - This ensures tests don't start before json_server is ready to respond - Should fix race condition causing 'Cannot read properties of undefined' errors in CI
1 parent 0498937 commit 7bb7e62

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/docker-compose.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ services:
1111
- MOCK_SERVER_HOST=mock_server
1212
command: ['/codecept/node_modules/.bin/mocha', 'test/rest']
1313
depends_on:
14-
- json_server
15-
- mock_server
14+
json_server:
15+
condition: service_healthy
16+
mock_server:
17+
condition: service_started
1618

1719
test-acceptance.webdriverio:
1820
build: ..
@@ -72,6 +74,12 @@ services:
7274
ports:
7375
- '8010:8010' # Expose to host
7476
restart: always # Automatically restart the container if it fails or becomes unhealthy
77+
healthcheck:
78+
test: ["CMD", "node", "-e", "require('http').get('http://localhost:8010/posts', (res) => process.exit(res.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"]
79+
interval: 2s
80+
timeout: 3s
81+
retries: 10
82+
start_period: 5s
7583

7684
mock_server:
7785
<<: *test-service

0 commit comments

Comments
 (0)