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

192
Visualizações
Testing React Native Hook with Jest

I've got a basic React Native app that has been barely modified and initialized using Expo:

expo init AwesomeProject

cd AwesomeProject
yarn start

The initialized app has this class:

import {
  ColorSchemeName,
  useColorScheme as _useColorScheme,
} from "react-native";

export default function useColorScheme(): NonNullable<ColorSchemeName> {
  return _useColorScheme() as NonNullable<ColorSchemeName>;
}

I'm going through the codebase and trying to add unit tests. I've added a few rendering tests for React Native components, but here I'm trying to unit test the useColorScheme() function. Since this is a React hook, I can't call it outside of a React function body.

// Using jest
import useColorScheme from "../useColorScheme";

it('useColorScheme', () => {
    const huh = useColorScheme();
});

So basically my question is - What's the best way to call a React hook using jest since the hooks can only be called from a React function? (Let it be noted that I am quite new to javascript, typescript, and React)

about 4 years ago · Juan Pablo Isaza
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