npm run compile is plain tsc -p ./ with no clean step, and out/ is never emptied. tsc writes new output over old but does not remove .js for sources that no longer exist. The mocha loader then globs whatever is there:
const files = fs.readdirSync(testsRoot).filter((f) => f.endsWith('.test.js'));
So a test file that has been deleted, renamed, or that simply belongs to a different branch keeps getting executed from out/ indefinitely.
This is not theoretical, it bit me while working on #1. Switching between branches left out/test/suite/ holding compiled tests from branches that were not checked out, and the run failed with no mocha output at all and the host exiting after about four seconds, which looks nothing like a test failure and sends you hunting through your own change for a startup crash that is not there. rm -rf out && npm run compile fixed it.
The quieter half is worse than the loud half: when a stale file happens to still pass, the suite reports a pass count that includes tests that are not in the tree you are looking at. I quoted such a number in an earlier PR before I noticed.
A clean step on pretest would settle it, something like:
"clean": "node -e \"require('fs').rmSync('out',{recursive:true,force:true})\"",
"pretest": "npm run clean && npm run compile"
Worth keeping it off compile itself so npm run watch and the F5 debug loop stay fast, and only paying the full rebuild where correctness of the file set actually matters.
Happy to send this one if you want it.
npm run compileis plaintsc -p ./with no clean step, andout/is never emptied.tscwrites new output over old but does not remove.jsfor sources that no longer exist. The mocha loader then globs whatever is there:So a test file that has been deleted, renamed, or that simply belongs to a different branch keeps getting executed from
out/indefinitely.This is not theoretical, it bit me while working on #1. Switching between branches left
out/test/suite/holding compiled tests from branches that were not checked out, and the run failed with no mocha output at all and the host exiting after about four seconds, which looks nothing like a test failure and sends you hunting through your own change for a startup crash that is not there.rm -rf out && npm run compilefixed it.The quieter half is worse than the loud half: when a stale file happens to still pass, the suite reports a pass count that includes tests that are not in the tree you are looking at. I quoted such a number in an earlier PR before I noticed.
A clean step on
pretestwould settle it, something like:Worth keeping it off
compileitself sonpm run watchand the F5 debug loop stay fast, and only paying the full rebuild where correctness of the file set actually matters.Happy to send this one if you want it.