So I have a file with utils:
import { someFunc, someOtherFunc } from 'someFile.js';
export const util1 = () => { return { abc: 1} };
export const util2 = (a, b) => { return someOtherFunc(a, b) + someFunc(a, b) };
Then I have another file with tests:
import { util1 } from 'utils.js';
describe('Whatever', () => {
it('Does something', () => {
const x = { a: 1 };
const y = util1(x);
expect(y).toEqual({ abc: 1 });
});
});
As you can see I'm not importing util2, but when I run jest, it breaks the test suite. This is because of someFunc, but that function is not being used here so I don't know how to ignore it...
npm install --save-dev @babel/plugin-transform-modules-commonjs
{
"env": {
"test": {
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
}
}
"type": "module" in your package.json