繁体   English   中英

即使已导入,也找不到模块

[英]Module not found even though it is imported

当我运行这个测试时:

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);
    });    
});

我收到此错误:

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 确实导入 ReissueService。 我需要模拟这个吗?如果需要,我该怎么做?

在 Reissue 中,我的导入是:

import { ReissueService } from 'src/services/ReissueService/ReissueService';

我正在出口:

export class Reissue extends React.Component<Props, State> {...

在 ReissueService 中,我导出:

export interface ReissueURL {...

export class ReissueService {...

我更改了import { ReissueService } from 'src/services/ReissueService/ReissueService'; import { ReissueService } from '../../services/ReissueService/ReissueService';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM