aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/dev-fkeys.el5
-rw-r--r--tests/test-dev-fkeys--f6-test-runner-cmd-for.el13
2 files changed, 12 insertions, 6 deletions
diff --git a/modules/dev-fkeys.el b/modules/dev-fkeys.el
index 0f120a8d..c760e392 100644
--- a/modules/dev-fkeys.el
+++ b/modules/dev-fkeys.el
@@ -364,9 +364,10 @@ TypeScript / JavaScript and unknown languages return nil."
(if (string-empty-p rel-dir)
"./"
(format "./%s" rel-dir)))))
- ('typescript
+ ((or 'typescript 'javascript)
;; Prefer vitest when present on PATH, fall back to jest otherwise.
- ;; Both runners take a path argument and accept relative paths.
+ ;; Both runners take a path argument and accept relative paths, and
+ ;; both run JS test files the same way they run TS ones.
(let ((runner (or (and (executable-find "vitest") "vitest")
(and (executable-find "jest") "jest")
"jest"))) ; reasonable default for stack traces
diff --git a/tests/test-dev-fkeys--f6-test-runner-cmd-for.el b/tests/test-dev-fkeys--f6-test-runner-cmd-for.el
index d7b6a059..59d0ba42 100644
--- a/tests/test-dev-fkeys--f6-test-runner-cmd-for.el
+++ b/tests/test-dev-fkeys--f6-test-runner-cmd-for.el
@@ -138,10 +138,15 @@ rather than a silent nil that F6's outer wrapper interprets as
'typescript t "src/foo.test.ts" "foo" "src")
"npx --no-install vitest src/foo.test.ts"))))
-(ert-deftest test-dev-fkeys-f6-cmd-for-javascript-returns-nil ()
- "Error: JavaScript is punted for v1 and returns nil."
- (should (null (cj/--f6-test-runner-cmd-for
- 'javascript t "src/foo.test.js" "foo" "src"))))
+(ert-deftest test-dev-fkeys-f6-cmd-for-javascript-uses-npx-runner ()
+ "Normal: javascript gets the same npx runner command as typescript.
+The language detector classifies js/jsx and the test-file detector
+recognizes JS test files, but the dispatch had no javascript arm, so
+C-F6 on a JS test errored even though the npx path would run it."
+ (cl-letf (((symbol-function 'executable-find) (lambda (&rest _) nil)))
+ (should (equal (cj/--f6-test-runner-cmd-for
+ 'javascript t "src/foo.test.js" "foo" "src")
+ "npx --no-install jest src/foo.test.js"))))
(ert-deftest test-dev-fkeys-f6-cmd-for-unknown-returns-nil ()
"Error: an unknown language returns nil."