Pavel Nasovich's Blog The Moderately Enthusiastic Programmer

Today I Learned: Mocking multiple named exports in Jest

I know only one way.

Mock it:

jest.mock('path/to/some/module', () => ({
    someNamedExportFromModule: jest.fn()
  }));

Then import it:

import {someNamedExportFromModule} from 'path/to/some/module';

Setup value to return:

someNamedExportFromModule.mockReturnValue('someValue');

???

You are the best.

gl hf

comments powered by Disqus