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

151
Views
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 answers
Answer question

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 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!