Jest PrettyFormatPluginError: val.getMockName не является функциейTypeError: val.getMockName не является функцией - PullRequest
0 голосов
/ 03 мая 2020

Я использую jest в моем nextjs приложении. вот конфиг:

module.exports = {
  /* add jest-canvas-mock for styling issues */
  setupFiles: ['<rootDir>/jest.setup.js', 'jest-canvas-mock'],
  testPathIgnorePatterns: ['<rootDir>/_next/', '<rootDir>/node_modules/'],
  moduleNameMapper: {
    '\\.(jpg|jpeg|ico|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
      '<rootDir>/__mocks__/fileMock.js',
    '\\.(css|less|scss)$': 'identity-obj-proxy',
  },
};

это содержимое fileMock. js file

module.exports = 'test-file-stub';

и это мой тестовый файл для компонента, который использует sass:

it('fund should renders correctly', () => {
   const component = <ReduxProvider initialState={mockState}>
        <IntlProvider>
          <Fund />
        </IntlProvider>
      </ReduxProvider>;

    const tree = renderer.create(component).toJSON();
    expect(tree).toMatchSnapshot();
  });

и вот ошибка:

PrettyFormatPluginError: val.getMockName не является функциейTypeError: val.getMockName не является функцией

  63 |   it('fund should renders correctly', () => {
  64 |     const tree = renderer.create(component).toJSON();
> 65 |     expect(tree).toMatchSnapshot();
     |                  ^
  66 |   });
  67 | });
  68 | 

ты хоть представляешь, что не так с моей конфигурацией?

...