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

135
Views
skip import React from 'react' from test file using jest?

I'm using testing-library with react

I have this in my test file

import React from 'react' // best if I can skip this in every test file
import { render, screen } from '@testing-library/react'

but I got this error

`@testing-library/react` import should occur before import of `react`

either I turn off the eslint rule for order or I can somehow skip doing import React in every single test file.

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

0

You can include this information in a src/setupTests.js file as follows see this question:

import { React } from 'react';

global.React = React;

If the setupTests.js does not run by default, you might need to modify the "test" property under "scripts" (if you are using that to run your test cases):

"test": "react-scripts test"

Reference: setupTests.js not loading automatically in CRA react app

Hope this helped.

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!