Jestjs 用笑话模拟破坏的导入?

Jestjs 用笑话模拟破坏的导入?,jestjs,Jestjs,我在开玩笑地模仿一个被破坏的导入 组件中包含已销毁的导入: import { getSomething } from 'utils/paymentUtils'; 在测试中: import React from 'react'; import { shallow } from 'enzyme'; import Component from 'components/Component'; import * as utils from 'utils/paymentUtils'; jest.mock

我在开玩笑地模仿一个被破坏的导入

组件中包含已销毁的导入:

import { getSomething } from 'utils/paymentUtils';
在测试中:

import React from 'react';
import { shallow } from 'enzyme';
import Component from 'components/Component';
import * as utils from 'utils/paymentUtils';

jest.mock('utils');

describe('Something', () => {
  let wrapper;    
  utils.getSomething.mockImplementation(() => 'Blah');
我得到的错误是:

无法从“Component.spec.js”中找到模块“utils”


您必须模拟模块本身,在本例中
utils/paymentUtils
您必须模拟模块本身,在本例中
utils/paymentUtils

您的组件是否在测试的同一目录中?请尝试模拟相同的路径:
jest.mock('utils/paymentUtils'))
您的组件是否在测试的同一目录中?请尝试模拟相同的路径:
jest.mock('utils/paymentUtils')