#!/usr/bin/env bash

# Detect GitHub Actions or GitLab CI
CI_ARG=""

if [[ -n "${GITHUB_ACTIONS:-}" || -n "${GITLAB_CI:-}" ]]; then
  CI_ARG="--ci"
fi

# Run Jest while forwarding all arguments
npx -y jest \
  --runInBand \
  --forceExit \
  --testTimeout=120000 \
  --testPathIgnorePatterns="\\.mjs$" \
  --detectOpenHandles \
  ${CI_ARG:+$CI_ARG} \
  "$@"