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

391
Views
Ignore imports when importing internal/external dependencies in Jest

I found questions related to this but not exactly what I was looking for. I am wondering if this is possible to do something along the lines of, if you mock a internal dependency (like a module/file you created) / external deps, can you ignore all imports in that file by default and only allow the ones you need?

Example, pretend the method foo is being tested, and its inside a file called Foo.js, I only need the camelCase depedency to work as normal cause its used inside the foo function, but the rest of the dependencies, can be mocked to avoid loading something i wish to not load (like some code thats just living in the file not in a class or method)

// Foo.js
const { get } = require('lodash');
const camelCase = require('camelcase');
const Bar = require('../../../Bar.js');
...

const foo = () => {
// need to test this method and only needs camelcase
...


} 

Is this possible to say "ignore every dependency, except this one if my test function requires (imports) the Foo.js file in order to test the foo function?

I am very new to Jest so Sorry if my question my not make perfect sense or maybe something simple, or a better solution. I am working with an existing code base and some includes get really deep with more and more imports more down the tree and I can only really work with whats in the test functions

thanks in advance!

about 4 years ago · Santiago Trujillo
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!