Closed jojojames closed 6 years ago
This advice without the kill-buffer works reasonably well for me with no downsides that I see yet.
(defun jj*--mocha-run (&optional mocha-file test)
"Run mocha in a compilation buffer.
If MOCHA-FILE is specified run just that file otherwise run
MOCHA-PROJECT-TEST-DIRECTORY.
IF TEST is specified run mocha with a grep for just that test."
(let ((test-command-to-run (mocha-generate-command nil mocha-file test))
(default-directory (mocha-find-project-root))
(compilation-buffer-name-function (lambda (_) "" "*mocha tests*")))
(compile test-command-to-run 'mocha-compilation-mode)))
(advice-add 'mocha-run :override 'jj*--mocha-run)
Wonder why we call kill-buffer here when the tests are ran?
Some downsides I've noticed include a stray window being created sometimes during test runs (guessing kill-buffer doesn't clean up the test window) and it being hard to do some 'automatic test run on file save' type feature since the window kind of pops in and out.