Function: projectile-test-at-point-jest-name
projectile-test-at-point-jest-name is a byte-compiled function defined
in projectile.el.
Signature
(projectile-test-at-point-jest-name NODE)
Documentation
Return the test name for the JS/TS call_expression NODE.
Matches it/test/describe calls (including member calls like
it.only or test.each) whose first argument is a string literal,
returning that string without the surrounding quotes. Return nil
otherwise.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-test-at-point-jest-name (node)
"Return the test name for the JS/TS `call_expression' NODE.
Matches `it'/`test'/`describe' calls (including member calls like
`it.only' or `test.each') whose first argument is a string literal,
returning that string without the surrounding quotes. Return nil
otherwise."
(let* ((fn (treesit-node-child-by-field-name node "function"))
(fn-name (when fn
(pcase (treesit-node-type fn)
("identifier" (treesit-node-text fn t))
("member_expression"
(when-let* ((object (treesit-node-child-by-field-name
fn "object")))
(when (equal (treesit-node-type object) "identifier")
(treesit-node-text object t))))))))
(when (member fn-name '("it" "test" "describe"))
(when-let* ((args (treesit-node-child-by-field-name node "arguments"))
(arg (treesit-node-child args 0 t)))
(when (member (treesit-node-type arg) '("string" "template_string"))
;; Strip the surrounding quotes/backticks.
(substring (treesit-node-text arg t) 1 -1))))))