How can I test a property on an object that may be of two different types using Jest and TypeScript?

Advertisements I have a function getFruit() that returns two possible types, Banana | Apple. I have a jest unit test that includes a test for a property that exists on one of the types, but not the other. In this case, Banana has the property peel but Apple does not. test(`gets a banana`, () =>… Read More How can I test a property on an object that may be of two different types using Jest and TypeScript?

Testing a Typescript React Component Giving Error on getByText

Advertisements I’m trying to add unit testing to an application written with Typescript and React. I have a very basic component just for the sake of simplicity. import React from "react"; import ReactDOM from "react-dom"; type TypeProps = { } type TypeState = { } class App extends React.Component<TypeProps, TypeState> { constructor(props:TypeProps) { super(props); this.state… Read More Testing a Typescript React Component Giving Error on getByText