-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 Bug: Watch mode (-w) does not re-run after a run did not find any tests #3851
Comments
Your reproduction steps are too imprecise to be usable.
|
I'll try to be more precise. When I say update here, open up your editor and change the file contents.
|
Automated MCVE (UN*X-only)$ cd /var/tmp
$ mkdir testwatch
$ cd testwatch
$ mkdir test bin
$ cat < EOF > "package.json"
{
"name": "testwatch",
"version": "1.0.0",
"description": "Issue 3851",
"main": "index.js",
"devDependencies": {
"mocha": "latest"
},
"directories": {
"bin": "./bin",
"test": "./test"
},
"scripts": {
"test": "mocha",
"test:watch": "mocha --watch"
},
"keywords": [
"mocha"
],
"author": "P. Roebuck <plroebuck@users.noreply.github.com>",
"license": "ISC"
}
EOF
$ npm install
$ cat < EOF > "bin/run_test.sh"
#! /bin/sh
PROJROOT="/var/tmp/testwatch"
SPECFILE="${PROJROOT}/test/bug-test.spec.js"
#RUNDIR="/var/run" # user acct has no permission to write
RUNDIR="/tmp"
PIDFILE="${RUNDIR}/testwatch.pid"
## Modify test specification
function init_test_script {
echo "describe('hello world', () => it('works'));" > ${SPECFILE}
}
function use_unmodified_test_script {
echo "**** unmodified" >&2; \
cat ${SPECFILE} >&2
}
function _use_empty_test_script {
echo "describe('hello world', () => {});" > ${SPECFILE}
}
function use_empty_test_script {
echo "**** replace with empty describe" >&2; \
_use_empty_test_script; \
cat ${SPECFILE} >&2
}
function _use_fixed_test_script {
echo "describe('hello world', () => it('does not trigger mocha'));" > ${SPECFILE}
}
function use_fixed_test_script {
echo "**** replace with valid describe" >&2; \
_use_fixed_test_script; \
cat ${SPECFILE} >&2
}
## Utility
function create_pidfile {
echo "$(ps -ef | grep _mocha | grep -v grep | awk '{print $2}')" > ${PIDFILE}
}
function kill_mocha {
pid=$(cat ${PIDFILE})
kill ${pid}
}
function pause {
sleep 10
}
function terminate {
echo "**** done" >&2; \
kill_mocha
}
## Cleanup
function cleanup {
err=$?
init_test_script
trap '' EXIT INT QUIT TERM
tput init
exit $err
}
function sig_cleanup {
trap '' EXIT # some shells will call EXIT after the INT handler
false # sets $?
cleanup
}
trap cleanup EXIT
trap sig_cleanup INT QUIT TERM
##
## Main
##
init_test_script
use_unmodified_test_script
(env DEBUG=* npm run test:watch &) && \
sleep 5; create_pidfile && \
pause; use_empty_test_script && \
pause; use_fixed_test_script && \
pause; terminate
EOF
$ chmod 755 bin/run_test.sh Run test $ cd /var/tmp/testwatch
$ bin/run_test.sh |
I can reproduce your results, but I can't tell you whether it's by design or not at this point (don't use |
Mocha's I guess this bug has something to do with that Mocha loads its test files with |
@stigok do you have some time left for me?
and give me some feedback, please? EDIT: it's not working, yet ... |
No, it made no difference. |
This doesn't reproduce for me on Mocha 10.2.0. Hooray 馃コ! Maybe #3912 happened to fix this? If anybody is still seeing this, please file a new issue with one of our new issue templates. They'll prompt for the info needed to help us triage the new issue. Cheers all! 馃 |
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
Starting mocha with
-w
watch argument does not make mocha re-run on file save when no tests were executed in the previous run.Steps to Reproduce
describe('hello');
mocha -w test-test.js
Expected behavior:
mocha -w
re-runs the test suite when file is edited againActual behavior:
mocha -w
process hangs on the stats from the last run, failing to re-run after file has been editedReproduces how often: 100%
Versions
mocha --version
andnode node_modules/.bin/mocha --version
: 6.0.2 and 6.0.2node --version
: v11.10.1The text was updated successfully, but these errors were encountered: