I'm trying to unit test a utility file (util.js) with jest and the file looks like,
// utils.js
import { something } from '@whatever/nothing';
export const myMethod = (parameter) => {
if (!something ) return 0;
return something.length + parameter.length;
};
// utils.test.js
import { myMethod } from '../utils';
test('myMethod', () => {
expect(myMethod('whatever').toEqual(12);
});
something is module which is exported with a value of 'temp'.
When I run the test file, something is always undefined and ends up returning 0. What is the right way to mock the module 'something' inside the test file and make it available in the test run?