/jest-test-mode

Emacs minor mode for running jest (Node.js test framework)

Primary LanguageShellGNU General Public License v3.0GPL-3.0

jest-test-mode.el

https://melpa.org/packages/jest-test-mode-badge.svg

Emacs minor mode for running jest (Nodejs test framework). Inspired by ruby-test-mode and cider-test.

Features

  1. Uses npx jest to execute tests. This respect your project’s version of jest.
  2. Keybindings to execute tests for the entire project, a test module, or a top-level test/describe block.
  3. File references in the Test Execution Buffer support jump to definition.

Keybindings

jest-test-mode comes with some default keybindings:

BindingAction
C-c C-t nRuns tests in the current buffer.
C-c C-t pRuns all tests in the project.
C-c C-t tRuns the it/test/describe block at the current point.
C-c C-t aRe-runs the previous test command.
C-c C-t d nRuns tests in the current buffer with node debugger.
C-c C-t d tRuns the describe block at the current point with node debugger.
C-c C-t d aRe-runs the previous test command with node debugger.

Installation

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)

Resources

Thanks to the following resources for building this layer:

License

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.

Testing Notes

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 git@github.com: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