Last active
January 21, 2025 20:16
-
-
Save jsjoeio/2a5e7eb4533922040190e87b90a5449c to your computer and use it in GitHub Desktop.
How to Run a Jest test multiple times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
i=1 | |
successes=0 | |
failures=0 | |
totalTests=10 | |
SUCCESS_CHECKMARK=$(printf '\342\234\224\n' | iconv -f UTF-8) | |
CROSS_MARK=$(printf '\342\235\214\n' | iconv -f UTF-8) | |
OUTPUT_FILE="jestOutput.txt" | |
until [ $i -gt $totalTests ]; do | |
echo "Attempt #$i" | |
if yarn test -i test_file_name >>"$OUTPUT_FILE" 2>&1; then | |
((successes = successes + 1)) | |
echo " $SUCCESS_CHECKMARK tests passed" | |
else | |
((failures = failures + 1)) | |
echo " $CROSS_MARK tests failed" | |
fi | |
((i = i + 1)) | |
done | |
echo "\n | |
Ran $totalTests Tests.\n | |
✅ Succeeded: $successes/10 | |
❌ Failed: $failures/10 | |
\n | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment