Jetbrains cannot resolve imported javascript spec helper files
Problem
The helpers jest moduleNameMapper entry is breaking the ability of Jetbrains IDEs to find the imported files:
UPDATE/SUMMARY
TL;DR: This is because Jetbrains (and probably other static analysis tooling) only understands Webpack aliases, not Jest moduleNameMapper entries. See comment below for details: #299576 (comment 682378461)
Currently, the best solution to pursue seems to be what @leipert suggested below:
teach jest to resolve via webpack (e.g. https://github.com/mkg0/jest-webpack-resolver) and move the config to webpack.
We would have to be careful with this, though, because Webpack aliases also apply to the production code, not just test code.
Details
Jetbrains is smart enough to follow webpack aliases, for example, ~/....
It also seems to be able to follow jest moduleNameMapper entries in SOME cases, for example import { TEST_HOST } from 'spec/test_constants'.
**UPDATE: import { TEST_HOST } from 'spec/test_constants'; does NOT resolve properly, which is expected, because it's not in the webpack aliases. It may have been working in these screenshots below only because it was manually configured somehow.
What also interesting is the "spec/test_constants" moduleNameMapper entry DOES include the __helpers__ path, so it's nothing about the underscores that's the problem, but seems to be something about the alias.
I don't know what's different about the '^helpers(/.*)$': '<rootDir>/spec/frontend/__helpers__$1' entry that it doesn't work.
I tried making one that was similar to spec/test_constants, but that didn't work either: '^spec/helpers$': '<rootDir>/spec/frontend/__helpers__'
I looked for some Jetbrains issues, but only found these two which don't seem helpful:
Action
In any case, it would be nice tochange this to something Jetbrains can handle, so the IDE behavior isn't broken for people.
The simplest fix would be to just change all the imports to be relative with ../.., but that would be a pain especially with deep nesting.
Or we could try to figure out what is different about this moduleNameMapper that doesn't work.
Any thoughts on what we should do?
From @leipert
So one of the things we could do, we could teach jest to resolve via webpack (e.g. https://github.com/mkg0/jest-webpack-resolver) and move the config to webpack or we could put the config elsewhere...

