Testing with Jest and Webpack aliases

前端 未结 7 1515
生来不讨喜
生来不讨喜 2020-12-14 14:48

I am looking to be able to use webpack aliases to resolve imports when using jest, and optimally, reference the webpack.aliases to avoid duplication.

Je

7条回答
  •  情深已故
    2020-12-14 15:13

    this solution works well for me:

    moduleNameMapper: {
        '^Screens(.*)': '/src/screens/$1',
        '^Components(.*)': '/src/components/$1',
        '^Assets(.*)': '/src/assets/$1',
        '^Services/(.*)': '/src/services/$1',
      },
    

提交回复
热议问题