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

275
Visualizações
¿Cómo reescribir prueba con broma?

Hola, tuve una prueba de instantánea simple, pero necesitaba guardar datos de la API con el kit de herramientas redux y, después de eso, siempre falla.

DashboardScreen.tsx

 const DashboardScreen = () => { // added block of code const dispatch = useDispatch(); const { data: userData } = useGetUserDataQuery(); useEffect(() => { if (userData) dispatch(setCurrentUser(userData)); }, [dispatch, userData]); // end of added block of code return ( <View style={styles.container}> <View style={styles.containerWidth}> <Image style={styles.logo} source={require('../../assets/images/KonektoSmart-logo.png')} /> </View> </View> ); };

y la prueba DashboardScreen-test-tsx

 test('renders correctly', () => { const tree = create(<DashboardScreen />).toJSON(); expect(tree).toMatchSnapshot(); });

● No se pudo ejecutar el conjunto de pruebas, pero probé algunas de las siguientes y no funcionó.

 [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null. To fix this issue try these steps: • Run `react-native link @react-native-async-storage/async-storage` in the project root. • Rebuild and restart the app. • Run the packager with `--reset-cache` flag. • If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app. • If this happens while testing with Jest, check out docs how to integrate AsyncStorage with it: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Para resolver este problema, necesitaba usar Provider . Para mí, los documentos no están claros al hacer eso. Código completo:

 import React from 'react'; import { create } from 'react-test-renderer'; import DashboardScreen from '../DashboardScreen'; import { Provider } from 'react-redux'; import store from '../../redux/store'; test('renders correctly', async () => { const tree = create(<Provider store={store}><DashboardScreen /></Provider>).toJSON(); expect(tree).toMatchSnapshot(); });
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