Skip to content

Commit 437e296

Browse files
authored
Update test-on-push.yml with selenium services
- Add services.selenium to set up the Selenium server using the selenium/standalone-chrome:latest Docker image. The server will be accessible on port 4444. - Add enchancement step "Wait for Selenium" to run a loop to check if the Selenium server is ready. It uses nc (Netcat) to test the connection to localhost:4444 and waits until it is available.
1 parent 8823004 commit 437e296

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

.github/workflows/test-on-push.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
name: test-on-push
2-
run-name: Test on push to ${{ github.ref }} by ${{ github.actor }}
2+
run-name: Test on push to ${{ github.ref_name }} by ${{ github.actor }}
33
on: push
44
jobs:
55
test:
66
runs-on: ubuntu-latest
7-
7+
services:
8+
selenium:
9+
image: selenium/standalone-chrome:latest
10+
ports:
11+
- 4444:4444
812
strategy:
913
matrix:
1014
node-version: [20.x, 21.x, 22.x]
11-
1215
steps:
1316
- name: Checkout repository
1417
uses: actions/checkout@v4
15-
1618
- name: Set up Node.js
1719
uses: actions/setup-node@v4
1820
with:
1921
node-version: ${{ matrix.node-version }}
20-
22+
- name: Cache Node.js modules
23+
uses: actions/cache@v4
24+
with:
25+
path: node_modules
26+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-
2129
- name: Install dependencies
2230
run: npm install
23-
31+
- name: Wait for Selenium
32+
run: |
33+
while ! nc -z localhost 4444; do
34+
echo "Waiting for Selenium to be ready..."
35+
sleep 1
36+
done
37+
echo "Selenium is ready!"
2438
- name: Run tests
2539
run: npm run test

0 commit comments

Comments
 (0)