tdnl / ra4-test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ra4-test

How was this project generated?

npx create-react-admin@latest ra4-test
npm i --save-dev vitest @testing-library/jest-dom @testing-library/react jsdom

Update vite.config.ts to setup vitest:

  // ...
  test: {
    globals: true,
    environment: "jsdom",
    threads: false,
    setupFiles: "src/tests/setup-tests.ts",
    include: ["**/*.spec.ts", "**/*.spec.tsx", "**/*.spec.js", "**/*.spec.jsx"],
  },
  // ...

Add test in script:

{
  "scripts": {
    "test": "vitest"
  }
}

The Issue

Running npm test will start vitest who will then fail because some tests are throwing errors:

TypeError: Cannot read properties of null (reading 'control')TypeError: Cannot read properties of null (reading 'control')

Test Pass Using RA Component Note
button-with-state.spec.tsx ✔️ Custom components
ra-button-with-state.spec.tsx ✔️
ra-toolbar-with-save.spec.tsx ✔️
toolbar-with-save-cjs.spec.tsx Files were taken from cjs folder in ra-ui-material-ui
toolbar-with-save.spec.tsx ✔️ Files were taken from esm folder in ra-ui-material-ui

About


Languages

Language:TypeScript 64.0%Language:HTML 31.7%Language:JavaScript 4.3%