if ! ${pkgs.nodePackages.pnpm}/bin/pnpm mocha --colors --jobs 1 --bail --recursive test/cases/
echo_section "run tests"
selection=$(gum choose "run specific test" "run all tests" "Cancel")
if [[ "$selection" == "Cancel" ]]; then
echo_text "Exiting."
exit 0
fi
if [[ "$selection" == "run all tests" ]]; then
echo_step "run specific tests"
if ! ${pkgs.nodePackages.pnpm}/bin/pnpm mocha --colors --jobs 1 --bail --recursive $TEST_CASES_PATH
then
echo "ERROR: Tests failed, check your JS!"
exit 1
fi
exit 0
fi
escaped_test_cases_path=$(printf '%s\n' "$TEST_CASES_PATH" | sed 's:[\\/&]:\\&:g;$!s/$/\\/')
echo_step "run all tests"
files=$(find $TEST_CASES_PATH -type f -name "*.mjs")
relative_files=$(echo "$files" | sed "s|''${escaped_test_cases_path}||g")
selected=$(echo "$relative_files" | gum filter --no-limit --header="Select the test case to run" --placeholder="Select test case to run, use tab to select multiple files")
if [[ -z "$selected" ]]; then
echo_text "No files selected. Exiting."
exit 0
fi
full_paths=$(echo "$selected" | sed "s|^|''${escaped_test_cases_path}|")
if ! ${pkgs.nodePackages.pnpm}/bin/pnpm mocha --colors --jobs 1 --bail --recursive $full_paths