Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--watch and .only conflict #888

Closed
rstacruz opened this issue Jun 5, 2013 · 9 comments · Fixed by #1172
Closed

--watch and .only conflict #888

rstacruz opened this issue Jun 5, 2013 · 9 comments · Fixed by #1172

Comments

@rstacruz
Copy link
Contributor

rstacruz commented Jun 5, 2013

Using it.only() with --watch yields unexpected results.

Steps:

  1. Run mocha --watch on your huge test suite
  2. Watch as how it runs 1,000 tests
  3. Mark one of those tests as it.only
  4. Watch as how it now runs just 1 test
  5. Now change back the it.only(...) to it(...)

Expected: run 1,000 tests
Actual: still running just one test

@faridnsh
Copy link

I just experienced this...

@tj
Copy link
Contributor

tj commented Jul 1, 2013

ugh.... really want to remove --watch

@benjamine
Copy link

what do you suggest instead? using another tool like grunt,js watch?

@faridnsh
Copy link

@benjamine I use nodemon for things that don't have a watch support. Works great. There's also node-supervisor.

@benjamine
Copy link

yes, I suppose some could get furious, but I agree --watch should deprecate.
To make it less traumatic someone could create a mocha-watch package by simply combining mocha and nodemon,
(that would allow integration with other apps, IDEs, notifiers, to move to that project)

@onetom
Copy link

onetom commented Nov 12, 2013

I just hit the same issue. I was using the https://github.com/alexch/rerun project but it was noticing the file changes very slowly, that's why i though i give a try to mocha -w
Trying nodemon now, but is there any new recommendation on this topic?

startswithaj added a commit to startswithaj/mocha that referenced this issue Mar 27, 2014
When .only() is used mocha.grep is set to the title of the .only test. This means that if --watch is on and it reruns the test and the .only has been removed the mocha.grep is still set to the same string. We clear mocha.grep on rerun and that means if .only has been moved or remains mocha.grep will be set again or remain cleared.
@startswithaj
Copy link
Contributor

The main issue here was that the global mocha.grep gets set to the title of the .only test. And then once you remove the .only test the mocha.grep remains set to the title. This fix simply resets the grep on rerun() which is the function --watch uses.

startswithaj added a commit to startswithaj/mocha that referenced this issue Mar 27, 2014
We want to clear mocha.grep if the grep is set via .only(). If it is set via the --grep option we want it to persist.
startswithaj added a commit to startswithaj/mocha that referenced this issue Mar 27, 2014
If mocha.grep is set via .only() we want to clear the grep on each rerun(). If the grep is set --grep we want it to persist.
startswithaj added a commit to startswithaj/mocha that referenced this issue Mar 27, 2014
@startswithaj
Copy link
Contributor

My initial PR didn't cover the scenario where you pass in a grep option via --grep and on rerun() it would get cleared. Now if you pass in a grep via --grep, mocha.grep is not cleared however greps created via .only() are.

@Guuz
Copy link

Guuz commented Aug 5, 2014

Having the same issue...

boneskull pushed a commit to boneskull/mocha that referenced this issue Sep 13, 2014
boneskull pushed a commit that referenced this issue Sep 13, 2014
#888 Fix for --watch+only() issue
tandrewnichols pushed a commit to tandrewnichols/mocha that referenced this issue Dec 15, 2014
bcowgill added a commit to bcowgill/mocha that referenced this issue Mar 28, 2021
When you change to dark mode in your OS, your mocha tests in the browser will follow suit.

There is a change needed in the javascript because the progress indicator canvas renders the 100% text in black.
I first tried using CSS only by changing the canvas background to a darker gray which made the text visible but the circle was then surrounded by a gray square in both light and dark modes.
I then tried changing the text color in the javascript to mochajs#888 as a middle point between black and white which was ok.
In the end I used the existing two colors for the circle as outline and fill color for the text, which looks pretty good.

I have tested this on Win10 Edge/Chrome switching the Color setting from control panel.

The file browser-color-scheme-demo.html is for reviewer's convenience to see it working.
Can be removed before final approval.

The files screenshot-mocha-*.png are for reviewer's convenience also, can be kept(moved somewhere) for adding to the documentation or removed before final approval.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants