Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda