Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

964
Views
React Testing Library - TypeError: actImplementation no es una función

Obtengo TypeError: actImplementation no es una función cuando intento una prueba simple para este componente

 import React from 'react'; import { StyledHeaderContainer, StyledTitle } from './styled'; export const Header = () => { return ( <StyledHeaderContainer> <StyledTitle data-testid='title-test-id'>Subject Access Request</StyledTitle> </StyledHeaderContainer> ); };

esta es mi prueba

 import * as React from 'react'; import 'jest-styled-components'; import { render, screen } from '@testing-library/react'; import { Header } from '../'; import "@testing-library/jest-dom"; describe('Header', () => { it('is rendered correctly', () => { expect(<Header />).toMatchSnapshot(); }); }); describe('Title', () => { it('should have correct text', () => { render(<Header />); expect(screen.getByTestId('title-test-id')).toHaveTextContent('Subject Access Request'); }) })

Está apuntando al render(<Header /) como el problema

¿Alguien tiene alguna idea?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Recibí el mismo error al usar react@17 , react-dom@18 y @testing-library-react@13 . Actualizar react a 18 resolvió el problema.

about 4 years ago · Juan Pablo Isaza Report

0

No está importando el encabezado correctamente, cambie la importación a:

 import { Header } from '../Header';

(o cualquier archivo que esté exportando el componente de encabezado)

Además, su primera prueba no está procesando un componente, por lo que la prueba está fallando.

cambiarlo a:

 it('is rendered correctly', () => { render(<Header />); expect(<Header />).toMatchSnapshot(); });
about 4 years ago · Juan Pablo Isaza Report

0

Bien, después de muchas pruebas y errores, resultó ser una solución simple. Apliqué esta importación en mi prueba, pero no la import * as React from 'react';

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!