Mocking meteor/cultofcoder:grapher-react with jest

I’ve been trying to mock a grapher function we are using like we mock meteor, but it doesn’t seem to be getting picked up and I’m stumped.

from various posts and other ‘research’, I found the cleanest way to do it is to include a file with mocks for meteor, and set your moduleNameMappers to go to that mock file. I’ve done so in my jest config as such:

  moduleNameMapper: {
    '^meteor/(.*)': '<rootDir>/tests/jest/frontend/meteor-mocks.js',

meteor-mocks.js has export const withQuery = () => {}, but I’m still getting this error when running tests:

TypeError: (0 , _cultofcodersGrapherReact.withQuery)(...) is not a function
on const enhancedNotificationsProvider = withQuery(() => getNotifications.clone({ isUnread: true, limit: null }),

I’ve tried explicitly user the package name as the moduleMapper key, importing grapher from the package and calling grapher.withQuery (and mocking grapher: { withQuery} in the mock), and even proxying the grapher package through a local package, but keep getting the same type of error.

Solved. Mock was incorrect. I had withQuery = () => {} instead of withQuery = () => () => {}

Cue facepalm