I am trying to do unit testing of my React app using Enzyme with Jest but getting this error
` FAIL src/components/XYZ/tests/ABC.test.js
● Test suite failed to run
SyntaxError: Name argument is not a valid custom element name.
Test Suites: 2 failed, 2 total Tests: 0 total Snapshots: 0 total Time: 3.224 s Ran all test suites.`
My Jest Config file is as following
"jest": {
"moduleNameMapper": {
"d3": "<rootDir>/node_modules/d3/dist/d3.min.js",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"^. \\.(css|less|scss)$": "identity-obj-proxy"
},
"setupFiles": [
"./src/"
],
"setupFilesAfterEnv": [
"./src/setUpTests.js"
],
"testPathIgnorePatterns": [
"./node_modules/"
]
},
Please let me know what I am doing wrong here ? TIA
CodePudding user response:
I think the configuration used for setupFiles is wrong here. As per jest documentation
https://jestjs.io/docs/configuration#setupfiles-array
setUpFiles is used for "A list of paths to modules that run some code to configure or set up the testing environment. Each setupFile will be run once per test file. Since every test runs in its own environment, these scripts will be executed in the testing environment before executing setupFilesAfterEnv and before the test code itself. "
Please either remove setUpFiles or use proper file path here .