簡體   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