是否可以在后台使用NX应用程序
我有一个NX MonorePo,上面有几个应用程序,包括Nestjs API和PostgreSQL数据库。我正在我的API上设置e2e
目标,以运行一套端到端测试。为了这样做,我希望使用我的API应用程序来执行我的测试。我正在使用@nrwl/jest:jest
执行程序来运行测试,目标包括dependson
,该 运行e2e-setup
target。 e2e-setup
目标使用@nrwl/workspace:run-commands
执行人运行npx nx nx nx run rest-api:服务
。我遇到的问题是服务命令块:终端固定在API过程中。我知道我可以用npx nx运行rest-api:serve&
在后台推动它,但是然后我必须脚本一些逻辑才能“等待”,直到API侦听为止。
似乎没有记录在后台服务NX应用程序的方法。那对吗?我认为最好的方法是通过docker-compose来容忍我的应用程序,并为我需要的一切(API,DB,REDIS等)提供服务,然后执行我的E2E测试。做这件事的最惯用方式是什么?
I have a Nx Monorepo with a couple apps including a NestJS API and a PostgreSQL database. I am setting up a e2e
target on my API to run a suite of end-to-end tests. In order to do so, I want my API app to be served to then execute my tests. I am using the @nrwl/jest:jest
executor to run the tests and the target includes a dependsOn
that runs a e2e-setup
target. The e2e-setup
target uses the @nrwl/workspace:run-commands
executor to run npx nx run rest-api:serve
. The problem I have is that the serve command blocks: the terminal stays attached to the API process. I know I can push it in the background with npx nx run rest-api:serve &
, but then I would have to script some logic to "wait" until the API is listening.
There does not seem to be a documented way to serve a Nx app in the background. Is that right? I am thinking perhaps the best approach would be to containerize my apps and serve everything I need (API, DB, Redis, etc.) through docker-compose to then execute my e2e tests. What would be the most idiomatic way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论