create-react-app
create-react-app copied to clipboard
Feature Request: Make it easier to use testing/test-running ability of react-scripts out of CRA apps
Is your proposal related to a problem?
Almost.
My scenario is that I have a non-CRA React app, with NextJS and custom babel configurations, using ts and tsx, it is inside a monolith, each package in the monolith uses different babel configurations and some of them are CRA. I wanted to write unit tests for this app I'm talking about, but I failed in every single way, it was hard to set up jest to be able to parse and run my tests when it was importing things from other packages. The first thing that hit my mind was to use react-scripts for running tests. Ultimately it did the job, but I had to eject, remove every ejected file related to building, watching & dev-server, and remove all unnecessary dependencies from package.json (this part was hard for me as this monolith takes a lot of time to re-install & re-link everything to make sure it is not broken) and probably I'm going to have lots of explanation to do to my colleagues why I did that:

Describe the solution you'd like
The actual problem was that react-scripts only looks in the src directory, but my app didn't have an src directory, I ejected everything just to be able to remove hard-coded src from jest configuration. (in the picture above I've removed it). It could be super cool if we supported src in overriding configurations: https://create-react-app.dev/docs/running-tests#configuration
Describe alternatives you've considered
configuring jest manually. But it was hard to do.