Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using babel-plugin-module-resolver with jest

I've got babel-plugin-module-resolver set up on my project and it works fine, until I run my tests.

I've set up ~/ to point to ./src.

I've tried adding the following to package.json but it still does not work

"jest": {
  "preset": "react-native",
  "moduleNameMapper": {
    "~": "./src"
  }
}
like image 537
Dan Avatar asked Dec 19 '18 10:12

Dan


1 Answers

You could use babel-jest plugin to make jest use babel as a preprocessor.

You can also find an example of this here

like image 140
mina sameh Avatar answered Oct 21 '22 21:10

mina sameh