是否可以在后台使用NX应用程序

发布于 2025-01-23 16:49:47 字数 592 浏览 1 评论 0原文

我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文