For me either of these worked
In package.json file adding test script env flag
"scripts": {
"test": "react-scripts test --env=jsdom"
}
Using enzyme
import { shallow } from 'enzyme';
it('renders without crashing', () => {
shallow(<App />);
});