React 19 - Objects are not valid as a React child
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Tranquilo
- Stack tecnológico
- javascript, react, vite
- Área
- testing
Línea de trabajo
Comienza con package.json y vitest.config.mjs y luego ejecuta npm run test contra button.test.tsx para reproducir el fallo de renderizado. Comprueba cómo se resuelven las versiones de React, React DOM, Vite y @testing-library/react en este paquete. Se considera terminado cuando pasan tanto la prueba simple de div como la prueba de renderizado de Button.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
@testing-library/reactversion: 16.3.0- Testing Framework and version: vitest 3.2.4
- DOM Environment: jsdom 26.1.0
Relevant code or config:
//package.json
{
"name": "@emg-hub/ui",
"version": "0.0.0",
"private": true,
"exports": {
"./*": "./src/*.tsx"
},
"scripts": {
"lint": "eslint . --max-warnings 0",
"generate:component": "turbo gen react-component",
"test": "vitest"
},
"devDependencies": {
"@emg-hub/eslint-config": "*",
"@emg-hub/typescript-config": "*",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/node": "^24.3.0",
"@types/react": "19.1.12",
"@types/react-dom": "19.1.9",
"@vitejs/plugin-react": "^5.0.2",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/ui": "^3.2.4",
"eslint": "^9.34.0",
"jsdom": "^26.1.0",
"typescript": "5.9.2",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.2.4"
},
"dependencies": {
"react": "^19.1.1",
"react-dom": "^19.1.1"
}
}
//vitest.config.mjs
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { configDefaults } from 'vitest/config'
export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
exclude: [...configDefaults.exclude, 'e2e/*'], // optional
coverage: {
provider: 'v8', // or 'c8'
reporter: ['text', 'json', 'html'],
exclude: ['vite.config.*', 'src/main.*', '**/*.d.ts', '**/__tests__/**'],
},
},
})
//button.tsx
import { ReactNode } from "react";
interface ButtonProps {
children: ReactNode;
className?: string;
appName: string;
}
export const Button = ({ children, className, appName }: ButtonProps) => {
return (
<button
className={className}
onClick={() => alert(`Hello from your ${appName} app!`)}
>
{children}
</button>
);
};
//button.test.tsx
import { render, screen, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { Button } from './button';
describe('Button', () => {
beforeEach(() => {
vi.clearAllMocks();
});
describe('rendering', () => {
it('renders simple div', () => {
render(<div>Click me</div>);
expect(screen.getByText('Click me')).toBeInTheDocument();
});
it('renders with children text', () => {
render(<Button appName="test">Click me</Button>);
expect(screen.getByRole('button', { name: 'Click me' })).toBeInTheDocument();
});
});
});
What you did:
Tried running simple test using npm run test
What happened:
I got the error "Objects are not valid as a React child (found: object with keys {$$typeof, type, key, props, _owner, _store}). If you meant to render a collection of children, use an array instead." even on the simple test 'renders simple div'
Problem description:
I can't seem to run any test on this React component, with React 19. I also tried using Jest but same issues. I followed a guide to setup my test config. It's a simple internal package in a turborepo arch. The issue is always on the render method of the @testing-library/react
Suggested solution
I don't have any. I saw a similar issue #1387 but it was for a NextJs project and the solution offered isn't possible for me.
- Lenguaje dominante
- JavaScript
- Estrellas
- 19.7k
- Forks
- 1.2k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testing-library/react-testing-library
-
fireEvent.select does not wrap its automatic native focus in actPosiblemente ocupada @sergioperezcheco la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict modeQuizá libre de nuevo @suhailopensource la tomó hace 72 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
testing-library/react-testing-library#1466 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
testing-library/react-testing-library#1459 · 2 comentarios ·
-
perf: optimize container lookup with early exitQuizá libre de nuevo @Ch-Abhinav-Chowdary la tomó hace 298 días y no hay ningún pull request abierto. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 35/100
testing-library/react-testing-library#1430 · 1 comentario ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)Posiblemente ocupada @swarnim02 la tomó hace 315 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
Todos los issues de testing-library/react-testing-library
Issues similares
-
Remove: Fox Deportes SDAbiertocheck:passed feeds:remove
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
iptv-org/database#37176 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 9 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
hawk-digital-environments/HAWKI#443 ·
Los mantenedores suelen responder en 1 día
-
documentation v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
modelcontextprotocol/python-sdk#3662 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
feedback simulation workshop
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
githubnext/gh-aw-workshop#4370 ·
Los mantenedores suelen responder en 1 día