I am mocking a component using jest.mock("../path/to/file")
.
If that mocked component moves around, Webstorm will fix all my imports. But it will not fix the path in the mock. I am trying to see if there is any way to solve this!
Something like…
import Component from "../../Component"
const pathToComponent = pathToFile(Component) // returns "../../Component", but this will change if the file moves.
Does such a function exist? Seems like it might be too meta…
(by the way, including the actual import to the component does not appear to break Jest’s mocking)