Open ScottFreeCode opened 8 years ago
+1 for this feature
A neat idea. I'm loathe to add anything to the "watch" functionality at this point though...
This would be a really great flag because I want to use --reporter min with --clearscreen false (or something similar). Right now using --reporter min always clears the screen and that does not work well for my needs.
I want this feature too. Since I guess it has been decided that this won't be added, I just hacked it in by adding console.log('\x1Bc');
to the reporters
directly.
Just edit node_modules/mocha/lib/reporters/
and add it manually where you see runner.on('start'...
.
Obviously it's not permanent, and has to be done for each repo, but it works well enough for me.
@brennancheung I didn't decide it wasn't to be added :wink: I'd just rather avoid piling features ontop of an already problematic feature.
+1
Or another option would be, if adding a flag is too complicated, to make a new reporter, call it even-more-min
, which does the exact same thing as min except for clearing the screen and setting the cursor.
I am running yarn mocha --recursive --watch --reporter min
This did not clear the screen when I saved a file I upgraded mocha from 3.2.0 to mocha@6.1.4
this had no effect. Screen output is not cleared at all.
Coming from Rails where I run Guard all the time with clearing :on - I don't know if I can live without it.
This did not clear the screen when I saved a file
Actually it seems to add a full page of black space which is not the clear
command
Maybe yarn blocks the clearing or translates it? I don't think this feature was ever implemented in mocha so the min reporter does still clear last I looked.
Try:
npx mocha --recursive --watch --reporter min
npx mocha --recursive --watch --reporter min Same result unfortunately. - Must be something project specific - thx anyway.
This did not clear the screen when I saved a file
Actually it seems to add a full page of black space which is not the
clear
command
@brentgreeff , the "min" reporter does this when run begins:
process.stdout.write('\u001b[2J');
From this documentation on ANSI-X3.64-1979 terminal control sequences, the code above should erase the entire display.
But I don't know the affect of --watch
off top of my head...
@plroebuck That just watches for changes to files under test. When a file changes a new test run is kicked off and if you're using the min reporter the screen will be cleared before each test new run.
For posterity...
If you are still looking for a solution to the original problem in this thread, which was to use the min reporter but have it not clear the console, here's the solution I finally came up with:
I created the custom reporter called even-more-min which is a clone of min, sans clearing.
npm install even-more-min --save-dev
npx mocha --reporter even-more-min
This works for me: https://www.npmjs.com/package/mocha-clearscreen-reporter
mocha --watch --reporter mocha-clearscreen-reporter
+
Seems reasonable to me. Maybe, --clear-screen
since other Mocha CLI flags use kebab-case (--allow-uncaught
, --async-only
, etc.)?
Tangentially related: TypeScript had the opposite behavior at first (always clear by default), but then added in a --preserveWatchOutput
flag: https://github.com/microsoft/TypeScript/issues/21295.
I cant believe its 8 years and this is still a (wrong) thing!
I cant believe its 8 years and this is still a (wrong) thing!
Believe it, @anodynos 😉. Mocha is a community-run open source project. There's no company employing developers working on it. Until recently there wasn't a consistently active maintenance team for several years.
If you want this issue resolved, send a pull request to implement the feature yourself. Comments expressing unhappiness at the situation don't help the conversation and just spam everyone subscribed to the thread.
In the meantime, https://github.com/mochajs/mocha/issues/2312#issuecomment-488121898 and https://github.com/mochajs/mocha/issues/2312#issuecomment-641172258 include links to community-authored workarounds.
We should add a
--clearscreen
flag that clears the console before a test run, for use with--watch
. This would be handy for reporters other than "min" (which has this effect built in and can be used as an example for implementation). It can currently be done with a globalbefore
hook, but that's clumsier than a flag would be (you have to go out of your way to set it up so that you can choose to include it or not as easily as if it were a flag) and could work incorrectly in the unlikely edge case that you have other globalbefore
hooks printing stuff.Inspired by @AshCoolman on Gitter.