marmelab / react-admin

A frontend Framework for single-page applications on top of REST/GraphQL APIs, using TypeScript, React and Material Design
http://marmelab.com/react-admin
MIT License
24.89k stars 5.23k forks source link

Unit Testing Edit components and Create components result to error #9886

Closed vforvaios closed 4 months ago

vforvaios commented 4 months ago

Hi everyone, and thumbs up for your great work!

So I am trying to write some vitest unit test for an Edit component (and Create also) using the tutorial on your website. So having a resource, and an edit component as follows: `

.....

`

So, when I try to write a test as follows: ` describe(...... it('.....', () => { render(

    )
})

)...... I get the following error: TypeError: Cannot read properties of undefined (reading 'toLowerCase') ❯ Object._apply_rules node_modules/inflection/lib/inflection.js:594:53 ❯ Object.singularize node_modules/inflection/lib/inflection.js:692:24 ❯ node_modules/ra-core/src/core/useGetResourceLabel.ts:46:44 ❯ useEditController node_modules/ra-core/src/controller/edit/useEditController.ts:113:15 ❯ EditBase node_modules/ra-core/src/controller/edit/EditBase.tsx:42:46 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 `

Other information:

Environment

djhi commented 4 months ago

Hi, and thanks for your question. As explained in the react-admin contributing guide, we use the GitHub issues for bugs and feature requests only.

For support question ("How To", usage advice, or troubleshooting your own code), you have three options:

If your problem is urgent, please consider subscribing to the Enterprise Edition, starting at 125€. It's a good way to contribute to the sustainability of react-admin.

So I'm closing this issue, and inviting you to ask your question in one of the support channels above.