[英]Module not found even though it is imported
When I run this test:当我运行这个测试时:
describe('<Reissue />', () => {
it('calls reissue service', () => {
const handleClose = () => null;
const disableButton = () => null;
const showPrompt = true;
const po = '123456';
const wrapper = shallow(<Reissue handleClose={handleClose} disableButton={disableButton} showPrompt={showPrompt} pol={pol}/>);
expect(wrapper.find('.reissue').length).toBe(1);
});
});
I get this error:我收到此错误:
Cannot find module 'src/services/ReissueService/ReissueService' from 'Reissue.tsx'
14 | interface State {
15 | confirmButton: boolean;
> 16 | confirmed: boolean;
17 | }
18 |
19 | export class Reissue extends React.Component<Props, State> {
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:169:17)
at Object.<anonymous> (src/components/reissue/ReissueCert.tsx:16:27)
Reissue.tsx does import ReissueService. Reissue.tsx 确实导入 ReissueService。 Do I need to mock this and if so how do I do that?我需要模拟这个吗?如果需要,我该怎么做?
In Reissue my import is:在 Reissue 中,我的导入是:
import { ReissueService } from 'src/services/ReissueService/ReissueService';
and I'm exporting:我正在出口:
export class Reissue extends React.Component<Props, State> {...
In ReissueService I export:在 ReissueService 中,我导出:
export interface ReissueURL {...
export class ReissueService {...
I changed import { ReissueService } from 'src/services/ReissueService/ReissueService';
我更改了import { ReissueService } from 'src/services/ReissueService/ReissueService';
to import { ReissueService } from '../../services/ReissueService/ReissueService';
import { ReissueService } from '../../services/ReissueService/ReissueService';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.