Is it possible to serve an Nx app in the background

Viewed 272

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?

0 Answers
Related