Jest .tsx Expo 34 with TypeScript, renderer.create Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object

So adding:

      "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "json",
      "jsx",
      "node"
    ]

to my jest configuration did the trick based on this - moduleFileExtensions: confusing documentation · Issue #7563 · facebook/jest · GitHub. I guess jest found app.json before App.tsx and then ran the test against that instead. Reordering the moduleFileExtensions to put .ts and .tsx before .json is why it works now. Hope this helps!

4 Likes