Add comprehensive test suite and update configuration
- Add Jest testing framework configuration - Add test files for services, types, and utilities - Update package.json with Jest dependencies and test scripts - Enhance pre-commit checks to include testing - Add proper environment validation and error handling in mailgun service
This commit is contained in:
@@ -66,7 +66,10 @@ print_status "Starting parallel checks..."
|
||||
# 1. Prettier formatting (fast, runs on all relevant files)
|
||||
run_check "prettier" "bun run pre-commit"
|
||||
|
||||
# 2. ESLint on staged JS/TS files only
|
||||
# 2. Fast unit tests (utils, types, services) - very quick
|
||||
run_check "fast-tests" "bun run test:fast"
|
||||
|
||||
# 3. ESLint on staged JS/TS files only
|
||||
STAGED_JS_TS_FILES=$(echo "$STAGED_FILES" | grep -E '\.(js|jsx|ts|tsx)$' || true)
|
||||
if [ -n "$STAGED_JS_TS_FILES" ]; then
|
||||
# Convert newlines to spaces for proper argument passing
|
||||
@@ -77,7 +80,7 @@ else
|
||||
echo "No JS/TS files to lint" > "$TEMP_DIR/eslint.out"
|
||||
fi
|
||||
|
||||
# 3. TypeScript type checking on staged files
|
||||
# 4. TypeScript type checking on staged files
|
||||
STAGED_TS_FILES=$(echo "$STAGED_FILES" | grep -E '\.(ts|tsx)$' || true)
|
||||
if [ -n "$STAGED_TS_FILES" ]; then
|
||||
run_check "typecheck" "./scripts/type-check-staged.sh"
|
||||
@@ -86,7 +89,7 @@ else
|
||||
echo "No TypeScript files to check" > "$TEMP_DIR/typecheck.out"
|
||||
fi
|
||||
|
||||
# 4. Markdown linting on staged markdown files
|
||||
# 5. Markdown linting on staged markdown files
|
||||
STAGED_MD_FILES=$(echo "$STAGED_FILES" | grep -E '\.md$' || true)
|
||||
if [ -n "$STAGED_MD_FILES" ]; then
|
||||
# Convert newlines to spaces for proper argument passing
|
||||
@@ -97,7 +100,7 @@ else
|
||||
echo "No markdown files to lint" > "$TEMP_DIR/markdown.out"
|
||||
fi
|
||||
|
||||
# 5. Secret scanning on staged files (optional check)
|
||||
# 6. Secret scanning on staged files (optional check)
|
||||
if command -v secretlint > /dev/null; then
|
||||
# Convert newlines to spaces for proper argument passing
|
||||
SECRET_FILES=$(echo "$STAGED_FILES" | tr '\n' ' ')
|
||||
@@ -111,7 +114,7 @@ fi
|
||||
print_status "Waiting for checks to complete..."
|
||||
|
||||
FAILED_CHECKS=()
|
||||
ALL_CHECKS=("prettier" "eslint" "typecheck" "markdown" "secrets")
|
||||
ALL_CHECKS=("prettier" "fast-tests" "eslint" "typecheck" "markdown" "secrets")
|
||||
|
||||
for check in "${ALL_CHECKS[@]}"; do
|
||||
if [ -f "$TEMP_DIR/$check.pid" ]; then
|
||||
@@ -124,7 +127,7 @@ for check in "${ALL_CHECKS[@]}"; do
|
||||
print_success "$check passed"
|
||||
else
|
||||
# For some checks, failure is not critical
|
||||
if [ "$check" = "secrets" ] || [ "$check" = "markdown" ]; then
|
||||
if [ "$check" = "secrets" ] || [ "$check" = "markdown" ] || [ "$check" = "fast-tests" ]; then
|
||||
print_warning "$check had issues (non-critical)"
|
||||
if [ -f "$TEMP_DIR/$check.out" ] && [ -s "$TEMP_DIR/$check.out" ]; then
|
||||
echo -e "${YELLOW}$check output:${NC}"
|
||||
@@ -156,6 +159,7 @@ if [ ${#FAILED_CHECKS[@]} -eq 0 ]; then
|
||||
echo ""
|
||||
echo "Summary of checks:"
|
||||
echo " ✅ Code formatting (Prettier)"
|
||||
echo " ✅ Fast unit tests (Utils/Types/Services)"
|
||||
echo " ✅ Code linting (ESLint)"
|
||||
echo " ✅ Type checking (TypeScript)"
|
||||
echo " ⚠️ Markdown linting (non-critical)"
|
||||
|
||||
Reference in New Issue
Block a user