I know this may have been posted before, but I'm really stuck as to why my tests aren't working in my React project. Here's my .babelrc file:
{
"presets": ["react", "es2015", "stage-0"],
"plugins": [
"transform-runtime",
"add-module-exports",
"transform-decorators-legacy"
],
"env": {
"development": {
"plugins": [
"typecheck",
["react-transform", {
"transforms": [{
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}]
}]
]
},
"test": {
"presets": ["es2015", "react", "stage-0"],
"plugins": [
"transform-runtime",
"add-module-exports",
"transform-decorators-legacy"
]
}
}
}
and here is my Jest setting in package.json
"jest": {
"moduleFileExtensions": [
"js",
"jsx",
"json"
],
"moduleNameMapper": {
"ExampleTest": "<rootDir>/app/pages/ExampleTest.js"
},
"moduleDirectories": [
"app",
"node_modules"
]
},
The error that I'm getting is Test suite failed to run... SyntaxError: Unexpected token <.
From what I can tell about that error, the files that it is trying to run have JSX/ES6 code in them... and it doesn't know how to transpile that? Which is weird because I've told it to do just that in the .babelrc. I have also provided Jest with the appropriate moduleDirectories.
Any help would be greatly appreciated.