Created
February 20, 2025 18:41
-
-
Save DavidWells/f77e35cbb1bbff49d0c2ef39dfb32c73 to your computer and use it in GitHub Desktop.
Bash for VSCode* to run tests in current file. E.g. Inside file.js will run file.test.js, inside file.test.js it runs itself
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
#!/bin/bash | |
if [[ "${relativeFile}" == *.test.js ]]; then | |
FILE="${relativeFile}" | |
elif [ -f "${fileDirname}/${fileBasenameNoExtension}.test.js" ]; then | |
FILE="${fileDirname}/${fileBasenameNoExtension}.test.js" | |
elif [ -f "${fileDirname}/$(basename "${fileDirname}").test.js" ]; then | |
FILE="${fileDirname}/$(basename "${fileDirname}").test.js" | |
else | |
FILE="${relativeFile}" | |
fi | |
echo "running file $FILE" | |
node "$FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment