Jest: cannot find module required inside module to be tested (relative path)

前端 未结 5 1339
耶瑟儿~
耶瑟儿~ 2021-02-13 15:49

I have this component:

import React from \'react\';
import VideoTag from \'./VideoTag\';
import JWPlayer from \'./JWPlayer\';

class VideoWrapper extends React.C         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-13 16:16

    I also had to add the moduleNameMapper to my jest configuration for my tsconfig path maps in order to get my tests to recognize the path maps I had setup. Something like this:

    "moduleNameMapper": {
          "^yourPath/(.*)": "\\yourPath\\$1"
        }
    

    Hopefully this will help someone down the line!

提交回复
热议问题