Emacs minor mode for running jest (Nodejs test framework). Inspired by ruby-test-mode
and cider-test
.
- Uses
npx jest
to execute tests. This respect your project’s version ofjest
. - Keybindings to execute tests for the entire project, a test module, or a top-level test/describe block.
- File references in the Test Execution Buffer support jump to definition.
jest-test-mode comes with some default keybindings:
Binding | Action |
---|---|
C-c C-t n | Runs tests in the current buffer. |
C-c C-t p | Runs all tests in the project. |
C-c C-t t | Runs the it/test/describe block at the current point. |
C-c C-t a | Re-runs the previous test command. |
C-c C-t d n | Runs tests in the current buffer with node debugger. |
C-c C-t d t | Runs the describe block at the current point with node debugger. |
C-c C-t d a | Re-runs the previous test command with node debugger. |
Install through melpa as jest-test-mode
.
To configure the project with use-package
:
(use-package jest-test-mode
:ensure t
:commands jest-test-mode
:hook (typescript-mode js-mode typescript-tsx-mode))
Manually:
(require 'jest-test-mode)
(add-hook 'typescript-mode-hook 'jest-test-mode)
(add-hook 'js-mode-hook 'jest-test-mode)
(add-hook 'typescript-tsx-mode-hook 'jest-test-mode)
Thanks to the following resources for building this layer:
- For inspiration and structuer: https://github.com/ruby-test-mode/ruby-test-mode
- For error highlighting: https://emacs.stackexchange.com/questions/27213/how-can-i-add-a-compilation-error-regex-for-node-js
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Verify package can be included cleanly:
# If using railwaycat/emacs, do this first
export EMACS_COMMAND=/Applications/Emacs.app/Contents/MacOS/Emacs.sh
# 1 Checkout melpa & cd in
git clone [email protected]:melpa/melpa.git && cd melpa
# 3 clean things up
git clean -fdx
# 4 package
make recipes/jest-test-mode
# 5 test-install
make sandbox INSTALL=jest-test-mode