Skip to content
29 changes: 28 additions & 1 deletion .github/workflows/js-css-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,30 @@ jobs:
run: npm i -w assets -w storybook -w tests/js --include-workspace-root
- name: Jest Tests
id: test-js
run: npm run test:js
run: npm run test:js -- -- --json --outputFile=../../jest-results.json
continue-on-error: true
- name: Check for catastrophic suite failures
id: check-catastrophic
run: |
# Ensure the Jest results file exists (the test script writes it two directories up from its working dir).
if [ ! -f jest-results.json ]; then
echo "❌ Catastrophic Jest failure: no jest-results.json produced (possible crash or misconfiguration)." >&2
exit 1
fi

if command -v jq >/dev/null 2>&1; then
NUM_RUNTIME_ERRORS=$(jq -r '.numRuntimeErrorTestSuites // 0' jest-results.json)
else
NUM_RUNTIME_ERRORS=$(node -e "const f=require('./jest-results.json');console.log(f.numRuntimeErrorTestSuites||0);")
fi

echo "Detected numRuntimeErrorTestSuites=$NUM_RUNTIME_ERRORS"
if [ "${NUM_RUNTIME_ERRORS}" -gt 0 ]; then
echo "❌ Catastrophic Jest failure: ${NUM_RUNTIME_ERRORS} test suite(s) had runtime errors (syntax/dependency issues). Aborting without retries." >&2
# Fail immediately so the job stops here.
exit 1
fi
echo "No catastrophic suite failures detected. Proceeding to potential retries for normal test failures."
- name: Jest Tests (Retry Failures 1)
id: test-js-retry-1
run: npm run test:js -- -- --onlyFailures
Expand All @@ -103,3 +125,8 @@ jobs:
- name: Jest Tests (Retry Failures 3)
run: npm run test:js -- -- --onlyFailures
if: steps.test-js-retry-2.outcome == 'failure'
- name: Clean up jest-results.json
run: |
if [ -f jest-results.json ]; then
rm -f jest-results.json
fi
Loading