     (kill-buffer "*mocha tests: debug*"))
   (let ((test-command-to-run (mocha-generate-command t mocha-file test))
         (root-dir (mocha-find-project-root))
-        (debug-command (concat mocha-which-node " debug localhost:5858")))
+        (debug-command (concat mocha-which-node " debug localhost:" mocha-debug-port)))
     (with-current-buffer (get-buffer-create "*mocha tests: debug*")
       (setq default-directory root-dir)
       (compilation-start test-command-to-run 'mocha-compilation-mode (lambda (m) (buffer-name)))

    (mocha-run file test-at-point)))

;;;###autoload
(defun mocha-debug-project ()
  "Debug the current project."
  (interactive)
  (mocha-debug))

;;;###autoload
(defun mocha-debug-file ()
  "Debug the current file."
  (interactive)
  (mocha-debug (buffer-file-name)))

;;;###autoload
(defun mocha-debug-at-point ()
  "Debug the current innermost 'it' or 'describe' or the file if none is found."
  (interactive)

  :type 'string
  :group 'mocha)

(defcustom mocha-debug-port "5858"
  "The port number to debug mocha tests at."
  :type 'string
  :group 'mocha)

(defvar mocha-project-test-directory nil)

(defvar node-error-regexp
