'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!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source