Skip to content

Commit

Permalink
Script that can detect failures in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Oct 5, 2023
1 parent a958876 commit b3c1e06
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scripts/test-watch-mode-works.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

out=$(mktemp)
# make silent background
npx mocha --watch 2>>$out.err 1>>$out &

PID=$!
#echo pid of mocha: $PID

echo "Round 1" >> out
touch src/fake-timers-src.js
sleep 3
echo "Round 2" >> out
touch src/fake-timers-src.js
sleep 2
echo "Cleanup" >> out

# Kill the process manually
kill $PID >/dev/null
kill -9 $PID >/dev/null

#cat $out.err
if grep failing $out; then
echo "This means some tests do not clean up after themselves or otherwise do not work in Mocha's watch mode"
echo "See $out for details or run $0 yourself"
exit 1
fi
exit 0

0 comments on commit b3c1e06

Please sign in to comment.