0

I really enjoyed using this projectile function in other languages but I'm currently having a hard time trying to figure out a way to set it for a typical TypeScript project.

ls services/
foo.service.ts foo.service.spec.ts bar.ts bar.spec.ts

When I execute projectile-toggle-between-implementation-and-test in any of these 4 files I get the following error:

helm-M-x-execute-command: No matching test file found for project type ‘npm’

In other words, the rule is try to find a file in the same directory with/without *.spec.ts* suffix

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91

1 Answers1

0

Turns out it is pretty simple. You need to evaluate the following snippet(notice the npm project-type):

(defun projectile-test-suffix (project-type)
  "Find default test files suffix based on PROJECT-TYPE."
  (cond
   ((member project-type '(emacs-cask)) "-test")
   ((member project-type '(rails-rspec ruby-rspec)) "_spec")
   ((member project-type '(rails-test ruby-test lein-test boot-clj go)) "_test")
   ((member project-type '(scons)) "test")
   ((member project-type '(npm)) ".spec")
   ((member project-type '(maven symfony)) "Test")
   ((member project-type '(gradle gradlew grails)) "Spec")))
BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
  • I'm not familiar with TypeScript, but it might be a better idea to define some TS project type if it can identified based on its file structure. – Bozhidar Batsov Nov 21 '20 at 19:17