Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
Unit test in React requires construct or call signatures

Having this React component:

import { Meta } from '@storybook/react';

export function MyExample() {
  return (
    <div>my example</div>
  );
}

export default {
  component: MyExample,
  title: 'MyExample'
} as Meta;

I want to write some unit tests for it, so this is the approach:

import { render } from '@testing-library/react';

import MyExample from './MyExample.stories';

describe('MyExample', () => {
  it('should render MyExample successfully', () => {
    const { baseElement } = render(<MyExample />);
    expect(baseElement).toBeTruthy();
  });
});

However, it has an error. A red line appears under the render's argument stating:

JSX element type 'MyExample' does not have any construct or call signatures

Any ideas how to fix this? I mention that it is done with Typescript.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

MyExample in your code is not exported as default.

So you need to change your import statement to:

import { MyExample } from './MyExample.stories'
// ...

You may want to use the eslint plugin import and the rule import/no-named-as-default to prevent this kind of error in the future.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda