Jest in dev dependencies, but no context menus or highlighting. What am I missing?
I have a multi-module (lambda function) NodeJS project (for reasons), and I'm a bit frustrated with the jest integration--the lack of it.
My main issue is the lack of a convenient "create jest test" context menu option. I used to have jest installed as a global dependency, but in attempting to get the jest (i.e., create test) context menus to show up, I switched to installing jest-cli globally and saving jest as a dev dependency of each function. That gave me the ability to run individual tests in manually created configurations, but still no context menu option.
Secondly, I can't get syntax highlighting without installing TypeScript.
Is this the expected behavior? I was told WebStorm functionality is subsumed by IDEA (or at least that's how I interpreted [this](https://intellij-support.jetbrains.com/hc/en-us/requests/1164771)), and I know I've seen the context menu affordances. Never had jest syntax highlighting without community stubs though.
Please sign in to leave a comment.
>I switched to installing jest-cli globally and saving jest as a dev dependency of each function. That gave me the ability to run individual tests in manually created configurations, but still no context menu option.
Works fine for me - if either jest-cli or jest are installed locally and added to dev dependencies, context actions are there. Can you share the project that shows up the issue?
>I can't get syntax highlighting without installing TypeScript. Is this the expected behavior?
Yes - as Jest module itself doesn't define describe(), test(), etc anywhere, they can't be resolved during static code analysis unless the library stubs are available
What do you mean by share? (And how did you quote text from my post?)
It's a work project. I could replicate the structure and share the replica.
If you can't share a project, try creating a sample app with similar structure. I don't need your actual source files, it can be a dummy project with similar configuration. But you should be able to recreate the issue with it - providing a project that doesn't show up any issues makes no sense
>And how did you quote text from my post?
there are no special actions for this :( To quote a text, I enter `>` to mark the quotation start, and use the italic style to visually highlight it
re quote: I'm just trying to figure out if I can use markdown or HTML or something for formatting. (...and I just noticed the WYSIWIG controls.)
Do you want me to zip and attach the project?
Okay... In the new project. I see "Create..." for 'handle.test.js' but not 'schemas.test.js'.
I'm guessing it's because the tests are generated.
How do I include the source or attach?
It's not working for this.
schemas.test.js
handle.test.js
vs.
schemas.test.js
Adding this on line 11 (in my real project) enables IntelliJ to detect the file as a jest file.
the problem is that your schemas.test.js is not recognized as a spec file - note its icon: it is a raw js file icon, not the js test one, like the one used for handle.test.js
Test file recognition is based on static analysis of a JavaScript file that looks for top-level methods with names matching predefined patterns (e.g. 'describe', 'ddescribe', 'fdescribe', 'it', 'iit', etc). That's why it fails if the suite is wrapped in some other calls/generated dynamically. Related tickets: https://youtrack.jetbrains.com/issue/WEB-8425, https://youtrack.jetbrains.com/issue/WEB-28462, https://youtrack.jetbrains.com/issue/WEB-20442
I don't know what a "spec" file is, but I get the bit about static analysis. It's easy enough to add a random test block somewhere, use the context menu option and then remove it.
Thanks for the help!
--Leora