Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Find path to an imported element

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)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!