Write tests. Not too many. Mostly integration.
Testing implementation details
How to know what to test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return ( | |
<> | |
{showCorrectAnswerCard ? ( | |
<View style={{marginVertical: 5}}> | |
<Card status={'success'}> | |
<Text>Correct 🥳</Text> | |
</Card> | |
</View> | |
) : null} | |
{showWrongAnswerCard ? ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {fireEvent, render} from '@testing-library/react-native'; | |
import * as eva from '@eva-design/eva'; | |
import {ApplicationProvider} from '@ui-kitten/components'; | |
import {IQuestion} from '../types'; | |
import {Question} from '../Question'; | |
describe('<Question />', () => { | |
const questionProp: IQuestion = { | |
id: '123-ABC', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return ( | |
<SafeAreaView> | |
<ScrollView style={{padding: 10}}> | |
{!quizIsDone ? ( | |
<> | |
<View> | |
{questions && questions.length > 0 ? ( | |
<Question | |
question={questions[currentQuestion]} | |
onSubmit={onSubmit} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {Provider} from 'react-redux'; | |
import {configureStore} from '@reduxjs/toolkit'; | |
import {fireEvent, render} from '@testing-library/react-native'; | |
import {ApplicationProvider} from '@ui-kitten/components'; | |
import * as eva from '@eva-design/eva'; | |
import questionsReducer from '../../questions/questionsSlice'; | |
import QuizScreen from '../QuizScreen'; | |
jest.mock('react-native-toast-message', () => ({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '@testing-library/jest-native/extend-expect'; | |
import 'react-native'; | |
import 'jest-enzyme'; | |
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; | |
import Enzyme from 'enzyme'; | |
/** | |
* Set up DOM in node.js environment for Enzyme to mount to | |
*/ | |
const {JSDOM} = require('jsdom'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react'; | |
import { | |
SafeAreaView, | |
Text, | |
View, | |
TextInput, | |
} from 'react-native'; | |
const Name = () => { | |
const [name, setName] = useState(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Enzyme, {shallow} from 'enzyme'; | |
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; | |
import Name from './Name'; | |
Enzyme.configure({adapter: new Adapter()}); | |
describe('<Name />', () => { | |
let wrapper: any; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {fireEvent, render} from '@testing-library/react-native'; | |
import Name from './Name'; | |
describe('<Name />', () => { | |
let getByText: any, getByTestId: any; | |
beforeEach(() => { | |
({getByText, getByTestId} = render(<Name />)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Amplify.configure({ | |
...awsconfig, | |
DataStore: { | |
authModeStrategyType: AuthModeStrategyType.MULTI_AUTH | |
} | |
}) |