test_unit_run_dir 836 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. declare -a vitest_args=("$@")
  3. if [[ -n "$MOCHA_GREP" ]]; then
  4. vitest_args+=("--testNamePattern" "$MOCHA_GREP")
  5. fi
  6. if [[ -n "$VITEST_NO_CACHE" ]]; then
  7. echo "Disabling cache for vitest."
  8. vitest_args+=("--no-cache")
  9. fi
  10. echo "Running unit tests in directory: $*"
  11. npm run test:unit:parallel -- "${vitest_args[@]}"
  12. vitest_parallel_status=$?
  13. npm run test:unit:sequential -- "${vitest_args[@]}"
  14. vitest_sequential_status=$?
  15. if [ "$vitest_sequential_status" -eq 0 ] && [ "$vitest_parallel_status" -eq 0 ]; then
  16. exit 0
  17. fi
  18. # Report status briefly at the end for failures
  19. if [ "$vitest_parallel_status" -ne 0 ]; then
  20. echo "Parallel tests failed with status: $vitest_parallel_status"
  21. fi
  22. if [ "$vitest_sequential_status" -ne 0 ]; then
  23. echo "Sequential tests failed with status: $vitest_sequential_status"
  24. fi
  25. exit 1