-
-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watch what the tests require? #139
Comments
yeah that's why I didn't want to add |
Thanks for keeping this open. Do you mean visionmedia/watch? I noticed it earlier today from @changelogshow. Isn't that more like repeat(1) or recall(1) -- to make a couple of names up? If I run Taking the suggested Inferring it from the test code would have been ideal. Somewhere in-between ideal and super, perhaps we could add a function to the api - called dependencies / watchlist or something? This way the tests can explicitly tell mocha what to watch when it does watch. I can have this configured externally with a |
the problem with |
Imo, a separate This is good for focused development - work on something specific until it passes. Up-arrow is ok for no watch. I'd rather just edit the code, save it, and hope for good growl news without going to terminal. Next, it's no biggie to do ctrl-c, up-arrow, |
a separate flag might make more sense here, not sure. I would be doing |
of-course |
ok, my last comment was silly --watch either takes an argument or it doesn't. we could reserve a special character to mean don't watch anything but the test file(s) - e.g. |
Why not just make it watch all the files in the current directory and any sub-directories? i.e. anything in your project changes, rerun the tests. |
@xcoderzach it's pretty inefficient on some platforms, we could maybe do it if we ignore node_modules |
@visionmedia I think inefficiency on some platforms would be an acceptable tradeoff, since the --watch flag isn't very useful on any platform as is. |
i dont find it useful at all personally haha but i'll try it out on a reasonably sized project in a bit and see how it does |
Watching a huge number of files works for node-supervisor, on mac and linux, even when all the files are on NFS |
later if we need to we can add |
With the actual implementation all my tests are executed, when I change a .coffee file, because I use the watch function of coffeescript to compile changed .coffee files. It would be better to have a parameter for the filetype, which should be watched. |
I had a problem with watch and symbolic links: Foo.app is a link so the error makes kinda sense. Any chance watch can ignore links? |
gah lol I hate watchers |
haha, but it's really awesome because it enables some real TDD. |
I'm always in the term, |
I guess it's a matter of taste. I find it very rewarding to write tests like this. Model should do xzy: Then you start implementing getFoo and see the test failing. However, everybody has a different workflow. |
to me --watch makes no sense:
thus if it passes I'm in the terminal to commit already, if not then I maybe lose 100ms looking at my editor again lol |
Just for the record, |
One way to solve this problem is to use the
or, for a slightly more complex case where you want to watch both your tests and your code:
And you can do |
Thanks @amfarrell this works great. here's an example with "test" : "mocha --colors --compilers js:babel/register ./tests/index.js",
"test:watch": "watch-run -i -p 'src/**/*,tests/**/*' npm run test" |
@amfarrell Thanks for that solution! |
e.g. previously i could do Thanks
|
A common mantra for tdd / bdd is: "write some tests that fail, make them pass", aka test-first. The current implementation of
--watch
just sits idle in this case. It's often hard to get the tests wrong, what's being tested is more in need of watching than the code that's testing it. I think node reloaders have already solved catching this. I haven't checked how, but if I had to guess: it's by checking what'srequire
d... For simplicity sake (and to avoid circular requires) just one level deep is all that's needed in most test cases. If what's tested changes, the tests run again.The text was updated successfully, but these errors were encountered: