BulletProofTest is a package that allows you to easily test a terminal command multiple times. Once complete or on failure the process will exit.
npm install --save bulletprooftest
For example the following command will run
npm test 100 times or until failure.
bulletprooftest --times=100 --command="npm test"
You can adjust times and command to your use case.