Variable: projectile-test-at-point-rules

projectile-test-at-point-rules is a customizable variable defined in projectile.el.

Value

Large value
((python-ts-mode :node-types ("function_definition") :name-fn
		 projectile-test-at-point-python-name :command-fn
		 projectile-test-at-point-python-command)
 (go-ts-mode :node-types ("function_declaration") :name-fn
	     projectile-test-at-point-go-name :command-fn
	     projectile-test-at-point-go-command)
 (js-ts-mode :node-types ("call_expression") :name-fn
	     projectile-test-at-point-jest-name :command-fn
	     projectile-test-at-point-jest-command)
 (typescript-ts-mode :node-types ("call_expression") :name-fn
		     projectile-test-at-point-jest-name :command-fn
		     projectile-test-at-point-jest-command)
 (tsx-ts-mode :node-types ("call_expression") :name-fn
	      projectile-test-at-point-jest-name :command-fn
	      projectile-test-at-point-jest-command)
 (ruby-ts-mode :node-types ("call" "method_call" "method") :name-fn
	       projectile-test-at-point-ruby-name :command-fn
	       projectile-test-at-point-ruby-command)
 (rust-ts-mode :node-types ("function_item") :name-fn
	       projectile-test-at-point-rust-name :command-fn
	       projectile-test-at-point-rust-command)
 (elixir-ts-mode :node-types ("call") :name-fn
		 projectile-test-at-point-elixir-name :command-fn
		 projectile-test-at-point-elixir-command)
 (java-ts-mode :node-types ("method_declaration") :name-fn
	       projectile-test-at-point-java-name :command-fn
	       projectile-test-at-point-java-command)
 (erlang-ts-mode :node-types ("fun_decl") :name-fn
		 projectile-test-at-point-erlang-name :command-fn
		 projectile-test-at-point-erlang-command)
 (fsharp-ts-mode :node-types ("function_or_value_defn") :name-fn
		 projectile-test-at-point-fsharp-name :command-fn
		 projectile-test-at-point-fsharp-command))

Documentation

Rules telling projectile-run-test-at-point how to run a single test.

An alist keyed by major mode symbol. The current buffer's mode is matched against the keys with derived-mode-p, so a rule keyed on a mode also applies to modes derived from it. Each value is a plist with the following keys:

:node-types - a list of tree-sitter node type strings; walking up
the parse tree from point, only nodes of these types are considered.

:name-fn - a function called with a matching tree-sitter node that
returns the test name string, or nil if the node isn't a test (in which case the walk continues upward).

:command-fn - a function called with the test name and the file
name (relative to the directory the command runs in, normally the project root) that returns the shell command to run.

This variable was added, or its default value changed, in projectile version 3.1.0.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defcustom projectile-test-at-point-rules
  (let ((jest-rule '(:node-types ("call_expression")
                     :name-fn projectile-test-at-point-jest-name
                     :command-fn projectile-test-at-point-jest-command)))
    `((python-ts-mode
       :node-types ("function_definition")
       :name-fn projectile-test-at-point-python-name
       :command-fn projectile-test-at-point-python-command)
      (go-ts-mode
       :node-types ("function_declaration")
       :name-fn projectile-test-at-point-go-name
       :command-fn projectile-test-at-point-go-command)
      (js-ts-mode ,@jest-rule)
      (typescript-ts-mode ,@jest-rule)
      (tsx-ts-mode ,@jest-rule)
      (ruby-ts-mode
       ;; RSpec examples are calls, Minitest cases are methods.
       :node-types ("call" "method_call" "method")
       :name-fn projectile-test-at-point-ruby-name
       :command-fn projectile-test-at-point-ruby-command)
      (rust-ts-mode
       :node-types ("function_item")
       :name-fn projectile-test-at-point-rust-name
       :command-fn projectile-test-at-point-rust-command)
      (elixir-ts-mode
       :node-types ("call")
       :name-fn projectile-test-at-point-elixir-name
       :command-fn projectile-test-at-point-elixir-command)
      (java-ts-mode
       :node-types ("method_declaration")
       :name-fn projectile-test-at-point-java-name
       :command-fn projectile-test-at-point-java-command)
      (erlang-ts-mode
       :node-types ("fun_decl")
       :name-fn projectile-test-at-point-erlang-name
       :command-fn projectile-test-at-point-erlang-command)
      (fsharp-ts-mode
       :node-types ("function_or_value_defn")
       :name-fn projectile-test-at-point-fsharp-name
       :command-fn projectile-test-at-point-fsharp-command)))
  "Rules telling `projectile-run-test-at-point' how to run a single test.

An alist keyed by major mode symbol.  The current buffer's mode is
matched against the keys with `derived-mode-p', so a rule keyed on a
mode also applies to modes derived from it.  Each value is a plist
with the following keys:

`:node-types' - a list of tree-sitter node type strings; walking up
the parse tree from point, only nodes of these types are considered.

`:name-fn' - a function called with a matching tree-sitter node that
returns the test name string, or nil if the node isn't a test (in
which case the walk continues upward).

`:command-fn' - a function called with the test name and the file
name (relative to the directory the command runs in, normally the
project root) that returns the shell command to run."
  :group 'projectile
  :type '(alist :key-type (symbol :tag "Major mode")
                :value-type (plist :tag "Rule"))
  :package-version '(projectile . "3.1.0"))