1#!/usr/bin/env bash
2
3set -eo pipefail
4
5script_dir="$(dirname "$0")"
6
7args=("$@")
8
9# If the command is used like `yarn test plugin`, set the --rootDir option to the `plugin` directory
10if [ "$1" == "plugin" ]; then
11  args=()
12  args+=("--rootDir")
13  args+=("plugin")
14
15  if [[ -f plugin/jest.config.js ]]; then
16    args+=("--config")
17    args+=("plugin/jest.config.js")
18  fi
19
20  # Push the rest of the arguments minus the `plugin` arg
21  args+=("${@:2}")
22fi
23
24if [[ -t 1 && (-z "$CI" && -z "$EXPO_NONINTERACTIVE") ]]; then
25  args+=("--watch")
26fi
27
28"$script_dir/expo-module-jest" "${args[@]}"
29