Skip to content

Commit 746333b

Browse files
committed
refactor: move REST tests from Docker to regular test suite
- Add test-server:writable script without --read-only flag - Add test:rest script to run REST tests - Include test:rest in main test command - Update GitHub workflow to run REST tests with writable server - Remove REST tests from docker-compose acceptance tests This fixes the data cleanup issues caused by --read-only mode in Docker environment. REST tests don't require Docker isolation and can run like other unit/runner tests. Results: 37/38 tests pass (vs 7 failures in Docker)
1 parent 680c183 commit 746333b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

.github/workflows/acceptance-tests.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ jobs:
3737
run: docker-compose build
3838
working-directory: test
3939

40-
# Run rest tests using docker-compose
41-
- name: Run REST Tests
42-
run: docker-compose run --rm test-rest
43-
working-directory: test
44-
4540
# Run WebDriverIO acceptance tests using docker-compose
4641
- name: Run WebDriverIO Acceptance Tests
4742
run: docker-compose run --rm test-acceptance.webdriverio

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ jobs:
3636
curl -sSf http://localhost:3001/api/users && break
3737
sleep 1
3838
done
39+
- name: Start test server
40+
run: nohup npm run test-server:writable &
41+
- name: Wait for test server
42+
run: |
43+
for i in {1..20}; do
44+
curl -sSf http://localhost:8010/posts && break
45+
sleep 1
46+
done
3947
- run: npm run test:unit
48+
- run: npm run test:rest
4049
- name: Stop mock server
4150
run: npm run mock-server:stop
4251

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"repository": "Codeception/codeceptjs",
5050
"scripts": {
5151
"test-server": "node bin/test-server.js test/data/rest/db.json --host 0.0.0.0 -p 8010 --read-only",
52+
"test-server:writable": "node bin/test-server.js test/data/rest/db.json --host 0.0.0.0 -p 8010",
5253
"mock-server:start": "node test/mock-server/start-mock-server.js",
5354
"mock-server:stop": "kill -9 $(lsof -t -i:3001)",
5455
"test:with-mock-server": "npm run mock-server:start && npm test",
@@ -58,8 +59,9 @@
5859
"prettier": "prettier --config prettier.config.js --write bin/**/*.js lib/**/*.js test/**/*.js translations/**/*.js runok.cjs",
5960
"docs": "./runok.cjs docs",
6061
"test:unit": "mocha test/unit --recursive --timeout 10000 --reporter @testomatio/reporter/mocha",
62+
"test:rest": "mocha test/rest --recursive --timeout 20000 --reporter @testomatio/reporter/mocha",
6163
"test:runner": "mocha test/runner --recursive --timeout 10000 --reporter @testomatio/reporter/mocha",
62-
"test": "npm run test:unit && npm run test:runner",
64+
"test": "npm run test:unit && npm run test:rest && npm run test:runner",
6365
"test:appium-quick": "mocha test/helper/Appium_test.js --grep 'quick' --reporter @testomatio/reporter/mocha",
6466
"test:appium-other": "mocha test/helper/Appium_test.js --grep 'second' --reporter @testomatio/reporter/mocha",
6567
"test:ios:appium-quick": "mocha test/helper/Appium_ios_test.js --grep 'quick' --reporter @testomatio/reporter/mocha",

0 commit comments

Comments
 (0)