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

137
Vistas
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 Respuestas
Responde la pregunta

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