Testing with @testing-library/react-native

Aperta
#211 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, react-native
Ambito
mobile, testing

Direzione di ricerca

Inizia eseguendo il test @testing-library/react-native mostrato e analizza il mock walkthroughable intorno a CopilotText. Confronta l’albero renderizzato con il componente Text e determina perché testID non viene esposto. Il lavoro è completato quando getByTestId('test-schedule-name') trova l’elemento CopilotText nella configurazione di test documentata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Current Behavior
Testing with @testing-library/react-native the CopilotText element is not found

Unable to find an element with testID: test-schedule-name
...
const CopilotText = walkthroughable(Text);
                                  ^

Input Code

import { walkthroughable, CopilotStep } from 'react-native-copilot';
...
const CopilotText = walkthroughable(Text);
...
<View>
  <CopilotStep order={2} name='name'>
    <CopilotText testID={'test-schedule-name'}>
      {this.props.scheduleName}
    </CopilotText>
  </CopilotStep>
</View>
...

The test

jest.mock('react-native-copilot', () => ({
    walkthroughable: WrappedComponent => ({ copilot, ...props }) => <WrappedComponent {...copilot} {...props} />,
}));

it('displays name', () => {
    const { getByTestId } = render(<MyComponent />);
    const scheduleName = getByTestId('test-schedule-name');
    ...
});

Expected behavior/code
Be able to select the CopilotText as the Text do

Environment

  • react-native-copilot: [e.g. v2.4.6]
  • react-native: 0.59.0
  • react-native-svg: 9.11.1

Possible Solution
Another way of mocking the module (?)

Lingua principale
TypeScript
Stelle
2.4k
Fork
425
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mohebifar/react-native-copilot

Tutte le issue di mohebifar/react-native-copilot

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.