Unable to run in Testing environment using default export + Vite/Vitest
dewald-els opened this issue ยท 7 comments
React-simple-keyboard version
Using version: 3.5.30
EDIT: Updated to version 3.5.32, however, the issue remains
Testing environment:
- VItest: ^0.25.8
- Vite: ^4.0.1
- @testing-library/jest-dom: ^5.16.5
- @testing-library/react: 13.4.0
Description
The Keyboard component works well during local serve and production builds. However, when running in a test environment, the keyboard component produces the following error message:
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check your code at index.tsx:224.
Steps i've attempted
- Removed the
createPortal
- Same result - Tried to test input with keyboard in isolation - Same result
- Tried to test only Keyboard - Same result
- Tried modifying import to
import * as Keyboard from "react-simple-keyboard
- Same result
Screenshots
Console error message
Import of component
Rendering component
@dewald-els Could you share a test repository for the issue you're seeing? That would help me to debug this issue. Thanks! Will reopen when that is provided.
@hodgef sure thing! Thanks for checking it out. I'll get a test repo ready tomorrow and share a link. I did fork the repo to try and isolate the issue, but didn't have much success :) Might be something with my implementation. I'll send the repo soon! ๐
@hodgef I've added you as a collaborator to a project that includes the keyboard test with Vite. Made it private, let me know if you have any trouble accessing it ๐
@dewald-els How do you run the tests (and the project in general)? There seems to be no scripts
in the package.json :\
@dewald-els How do you run the tests (and the project in general)? There seems to be no
scripts
in the package.json :\
Oh! It's a monorepo, I made it as close as possible to the actual project environment. You can run
npx nx test keyboard-test
Should've added that ๐ my bad
np! Try using this as the import. It worked for me:
import { KeyboardReact as Keyboard, SimpleKeyboard } from 'react-simple-keyboard';
@hodgef I know the issue is closed, but damn! you are amazing. How did i miss that! haha thanks so much for the quick feedback.