我正在尝试用Jest模拟销毁的导入。
组件中已破坏的导入:
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'
答案 0 :(得分:0)
您必须模拟模块本身,在这种情况下为utils/paymentUtils