Commit e54407c226c8ae85fc6a320dbac79d95a6cbf09f
1 parent
233d1634
chore(scripts): skip frontend test when no test script defined
Step 4/6 (npm test) blew up with 'Missing script: test' on a fresh frontend that hasn't wired up a test runner yet. Guard with a node-based check on package.json#scripts.test so the gate skips gracefully (with a log line) instead of failing. Lint/build still always run when frontend is tracked — only the test step is conditional on having a runner configured.
Showing
1 changed file
with
7 additions
and
1 deletions
scripts/test.sh
| @@ -42,7 +42,13 @@ if [ $HAS_FRONTEND -eq 1 ]; then (cd frontend && npm run lint); else echo "[test | @@ -42,7 +42,13 @@ if [ $HAS_FRONTEND -eq 1 ]; then (cd frontend && npm run lint); else echo "[test | ||
| 42 | 42 | ||
| 43 | echo "[test.sh] 4/6 unit + integration" | 43 | echo "[test.sh] 4/6 unit + integration" |
| 44 | if [ $HAS_BACKEND -eq 1 ]; then (cd backend && mvn -B test); else echo "[test.sh] skip backend test"; fi | 44 | if [ $HAS_BACKEND -eq 1 ]; then (cd backend && mvn -B test); else echo "[test.sh] skip backend test"; fi |
| 45 | -if [ $HAS_FRONTEND -eq 1 ]; then (cd frontend && npm test -- --run); else echo "[test.sh] skip frontend test"; fi | 45 | +if [ $HAS_FRONTEND -eq 0 ]; then |
| 46 | + echo "[test.sh] skip frontend test" | ||
| 47 | +elif node -e "process.exit(require('./frontend/package.json').scripts?.test?0:1)" >/dev/null 2>&1; then | ||
| 48 | + (cd frontend && npm test -- --run) | ||
| 49 | +else | ||
| 50 | + echo "[test.sh] skip frontend test (no 'test' script in frontend/package.json)" | ||
| 51 | +fi | ||
| 46 | 52 | ||
| 47 | echo "[test.sh] 5/6 E2E" | 53 | echo "[test.sh] 5/6 E2E" |
| 48 | echo "[test.sh] e2e 略" | 54 | echo "[test.sh] e2e 略" |