Tabcorp / atom-mocha-test-runner

Mocha test runner for Atom Editor
https://atom.io/packages/mocha-test-runner
MIT License
38 stars 18 forks source link

Add support for running mocha on file save #31

Open holyjak opened 9 years ago

holyjak commented 9 years ago

Hello,

It would be wonderful if there was an option to run Mocha every time I save a file in the project - essentially to emulate mocha --watch. I can currently do that from the command line but I would like to see the results in Atom the way this plugins displays them. I guess it would only require adding an option for it and, if true, listening on an event (buffer:saved?) and triggering mocha.

Thank you!

rprieto commented 9 years ago

Hi, great idea :+1: Do you think it should run the entire file, or re-run the last test you ran? (or either as an option?)

kiddkai commented 9 years ago

I think it should work like vim-mocha, you can define your short cut which can

  1. run all the tests
  2. run the test which your cursor focus on
  3. run current file

Then it don't even need to watch, just simple short cuts . On Fri, 8 May 2015 at 8:49 am, Romain Prieto notifications@github.com wrote:

Hi, great idea [image: :+1:] Do you think it should run the entire file, or re-run the last test you ran? (or either as an option?)

— Reply to this email directly or view it on GitHub https://github.com/TabDigital/atom-mocha-test-runner/issues/31#issuecomment-100041296 .

holyjak commented 9 years ago

The thing is I don't want to be required to press a shortcut, I want all the tests in all files to run automatically whenever I save any file. This is how we use mocha watch now. Automation and continuous testing FTW!

Forget software. Strive to make an impact, deliver a valuable change.

(Vær så snill og hjelp meg med å forbedre norsken min – skriftlig og muntlig. Takk!)

Jakub Holy Solutions Engineer | +47 966 23 666 Iterate AS | www.iterate.no The Lean Software Development Consultancy

I think it should work like vim-mocha, you can define your short cut which can

  1. run all the tests
  2. run the test which your cursor focus on
  3. run current file

Then it don't even need to watch, just simple short cuts . On Fri, 8 May 2015 at 8:49 am, Romain Prieto notifications@github.com wrote:

Hi, great idea [image: :+1:] Do you think it should run the entire file, or re-run the last test you ran? (or either as an option?)

— Reply to this email directly or view it on GitHub < https://github.com/TabDigital/atom-mocha-test-runner/issues/31#issuecomment-100041296

.

— Reply to this email directly or view it on GitHub https://github.com/TabDigital/atom-mocha-test-runner/issues/31#issuecomment-100059891 .

rprieto commented 9 years ago

I can see how "run on save" would be handy, but I like @kiddkai's idea. What about splitting this in 2 features?

What do you think?

holyjak commented 9 years ago

That sounds great!

Forget software. Strive to make an impact, deliver a valuable change.

(Vær så snill og hjelp meg med å forbedre norsken min – skriftlig og muntlig. Takk!)

Jakub Holy Solutions Engineer | +47 966 23 666 Iterate AS | www.iterate.no The Lean Software Development Consultancy

I can see how "run on save" would be handy, but I like @kiddkai https://github.com/kiddkai's idea. What about splitting this in 2 features?

-

Ability to run a whole project

  • ctrl-alt m on a describe/it = run current test
    • ctrl-alt-m in a file = run current file
    • new ctrl-alt-m with a folder selected in the tree, runs mocha that-folder
  • The existing re-run command (ctrl-shift-alt m) re-runs either of the 3 above. This should just work out of the box since it reuses the last Context object that was created.

    New option called [x] Re-run on save which always re-runs the last context (test, file, or folder). Maybe this should be easy to toggle on/off from the Packages context menu, not just the package settings page.

What do you think?

— Reply to this email directly or view it on GitHub https://github.com/TabDigital/atom-mocha-test-runner/issues/31#issuecomment-100759969 .

mrstux commented 7 years ago

I too would love this feature.

being able to run a folder of tests from the tree-view would be great. But also add a context menu. "Run Mocha-test-runner" or whatnot. That should work on both folders and tests.

If there are no tests in the current file... then ALL tests in a given location list should be run. This means you can trigger mocha-test-runner for a full test from any non test file.

I think the re-run on save option should re-run the last context if it is in the current file, and if there is no context then the whole file, which if this file contains no tests, should run the full test suite.

This will allow you to not bother about focussing on a context, and just hit ctrl/cmd-s to run the tests.

And if you do want to focus, then just focus on a context and hit ctrl-alt-m to focus on just that context from then on.

The only trick then I guess, is how do you decide NOT to attach to a file that isn't a test on save? perhaps allow setting a directory inclusion setting for run-on-save

--

alternatively again, if there are no tests, then run the root tests, which should probably be configurable.

That would allow you to focus on a given test file, a given test context or ALL tests, which'd run anytime you change a js and save.

merriam commented 7 years ago

In a terminal, you can run this by adding the '--watch' option.

misterbridge commented 6 years ago

You can just add the mocha --watch option within the package settings. The title bar adds late tests at the end of it.

Only problem is that there seem to not be any "autoscroll".