Skip to content

Instantly share code, notes, and snippets.

@mturley
Last active July 31, 2019 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mturley/a769bcc661f7208b876383cd087fcc86 to your computer and use it in GitHub Desktop.
Save mturley/a769bcc661f7208b876383cd087fcc86 to your computer and use it in GitHub Desktop.
Script for getting started with unit tests in a directory full of new JS code
#!/usr/bin/env bash
pwd
mkdir -p ./__tests__
for file in *
do
if test -f "$file" && [[ $file == *.js ]]
then
testfile="./__tests__/${file/\.js/.test.js}"
if test -f "$testfile"
then
echo "File already exists: $testfile"
else
echo "Creating $testfile"
printf "// TODO\n\ntest.todo('unit tests for $file');\n" > $testfile
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment