我知道我可以运行npm testwhichreact-script test并且它可以工作,它成功地运行了测试。但我有兴趣弄清楚如何使用jest相同的配置直接运行react-script。希望不必复制配置或弹出应用程序。我开始阅读的源代码,react-scripts但到目前为止我无法弄清楚。
想要这个的原因是:
jest在顶层运行并运行所有测试。如果我jest在我的 CRA 应用程序上运行,我会收到此错误:
PS C:\Users\pupeno\Documents\Flexpoint Tech\js\exp7\frontend> jest
FAIL src/App.test.tsx
? Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use …Run Code Online (Sandbox Code Playgroud)