When I run my tests I get an error SyntaxError: Cannot use import statement outside a module. From this answer it is unclear to me what is needed to be done.
- I do not have a .babelrc file.
- Adding "type": "module" to package.json did not work.
From the update for 2020 I am guessing I add a jest configuration file but there are additional points like running node with --experimental-vm-modules and Run your test with jest-environment-node or jest-environment-jsdom-sixteen that I am not sure how to do.
Currently the command to run the tests is "test": "react-scripts test --env=jsdom",. From experience I can change this script to react-scripts test --env=jest-environment-node. But then I run into errors about a window not being defined. So it seems that what I want is to have both jsdom and jest-environment-node but that doesn't make sense.
How can I use import AND have window defined for tests?