CPSC270
Software Engineering and Project Design

Activity 30

Testing - Testing Library

Write Jest tests using React Naive Testing Library for the following component:

import React, { useState } from 'react';
import { Text, View, TouchableOpacity } from 'react-native';

export default function App() {
  const [cnt, setCnt] = useState(0);
  return (
    <View>
      <TouchableOpacity
        accessibilityLabel="Press Me!"
        onPress={() => {
          setCnt(cnt + 1);
        }}>
        <Text>Press Me!</Text>
      </TouchableOpacity>
      <Text
        accessibilityLabel="Press Count">
        {`${cnt}`}
      </Text>
    </View>
  );
}