Cannot create test file via cmd-shift-T
In IntelliJ I was used to having test files created for me automatically via the shortcut cmd-shit-T. However in WebStorm I can't get that working.
My setup:
- react/redux project
- /test directory *has* been marked as a test directory
- cursor is currently in a file lib/foo.js which is just a vanilla js file exporting a few functions
When I press cmd-shift-T I get the following error, rather than creating a test file for me: "no test subjects found"
请先登录再写评论。
WebStorm doesn't support creating spec files. But `Cmd+Shift+T` (
Navigate | Test) allows jumping to existing spec file (if any). Linking is based on test files/folders names, e.g. performingNavigate | Testinside a file namedMy.jswill navigate you toMySpec.jsfile. Patterns are hardcoded to*Spec.js,*_spec.js,*-spec.js,*.spec.*(+same patterns with "test" instead of "spec"). Also, it works for relative paths, e.g. it will navigate from "my-app/src/main/javascript/acme/Foo.js" to "my-app/test/main/javascript/acme/Foo.js" (or "my-app/src/test/javascript/acme/Foo.js", or "my-app/src/main/test/acme/Foo.js", etc.)I wouldn't call what we have a 'spec' file, it's a pretty standard test setup - a test/ dir whose structure roughly mirrors that of our lib/ dir.
So you say navigation is based on naming? Interesting, I see that that changing my test name to add '-test' at the end does help by enabling cmd-shift-T to navigate there.
However what you say about 'relative paths' does not seem to work for me. If I'm in lib/foo/bar.js then cmd-shift-T will *not* take me to test/foo/bar.js. Did I misunderstand?
I wish there was a way to *create* a test for me. Having to manually navigate my test/ dir and then manually create a file is cumbersome.
Are there any shortcuts?
>However what you say about 'relative paths' does not seem to work for me. If I'm in lib/foo/bar.js then cmd-shift-T will *not* take me to test/foo/bar.js. Did I misunderstand?
Works fine for me - I can navigate from `lib/foo/bar/bar.js` to `test/foo/bar/bar.js`
can you provide a sample project that shows up the issue?
>I wish there was a way to *create* a test for me
no. If you miss this feature, please feel free to file a request for it to youtrack, https://youtrack.jetbrains.com/issues/WEB