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. Do I need to mock this and if so how do I do that?
In Reissue my import is:
import { ReissueService } from 'src/services/ReissueService/ReissueService';
and I'm exporting:
export class Reissue extends React.Component<Props, State> {...
In ReissueService I export:
export interface ReissueURL {...
export class ReissueService {...
I changed import { ReissueService } from 'src/services/ReissueService/ReissueService';
to import { ReissueService } from '../../services/ReissueService/ReissueService';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.