Closed epsilon11101 closed 10 months ago
I am not sure yet how to test these elements. They are not designed to be rendered in pure DOM or testing env. And I don't think @testing-library
can catch context of react-konva
rendering.
yep, i figure out it , i used a simple solution to fix it, but thanks any way
const isTestEnv = process.env.NODE_ENV === "test";
return isTestEnv ? (
<div>
.......
</div>
) : (
<Html>
.....
</Html>
);
package.json
{ "name": "ix2code-editor", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint", "prodTest": "jest", "test": "jest --watchAll", "coverage": "jest --coverage" }, "dependencies": { "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.13", "@mui/material": "^5.14.13", "@mui/types": "^7.2.6", "@types/css-mediaquery": "^0.1.4", "@types/dropzone": "^5.7.6", "css-mediaquery": "^0.1.2", "jotai": "^2.4.3", "jotai-xstate": "^0.3.0", "konva": "^9.2.2", "nanoid": "^5.0.2", "next": "13.5.4", "normalize.css": "^8.0.1", "react": "^18", "react-dom": "^18", "react-dropzone": "^14.2.3", "react-hook-form": "^7.47.0", "react-konva": "^18.2.10", "react-konva-utils": "^1.0.5", "xstate": "^4.38.3" }, "devDependencies": { "@testing-library/jest-dom": "^6.1.3", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.5.1", "@types/jest": "^29.5.5", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", "eslint": "^8", "eslint-config-next": "13.5.4", "eslint-plugin-jest-dom": "^5.1.0", "eslint-plugin-testing-library": "^6.1.0", "jest": "^29.7.0", "jest-canvas-mock": "^2.5.2", "jest-environment-jsdom": "^29.7.0", "typescript": "^5" } }
Component:
SIMPLE TEST:
ERROR:
` console.error Warning: is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
at Group
at Html (/home/sa/Documents/IXMATIX/yuyu-frontend/code/yuyu-frontend/node_modules/react-konva-utils/lib/html.js:34:17)
at boxProps (/home/sa/Documents/IXMATIX/yuyu-frontend/code/yuyu-frontend/src/components/UI/Canvas/KonvaContainer/ContextMenu/ContextMenu.tsx:17:24)
● ContextMenu › should render ContextMenu
I try everything, the errors disappear when I replace HTML with another tag like Group, etc., but I need the HTML tag. So, how can I fix that? How can I test this?