Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting SyntaxError: Name argument is not a valid custom element name

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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 .

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading