How can I run the command to serve the app, and then run the command to fire e2e tests locally?

I am using nx for an application. I want to run the command nx serve which will serve my application, and once it is live on localhost: some port, I want to run the command to fire e2e tests to use that localhost URL. However, I want to automate this process, like running a command nx serve and then when that command is finally started serving the app, firing e2e automatically https://100001.onl/. I can’t do nx serve && npm run tests because the nx serve is an ongoing process. If it helps, nx does it internally but with cypress. There is an option to build and test the app with cypress at the same time. I am not using cypress, unfortunately. Do you guys have any clue how nx achieves this internally? Or how I can achieve this? Thank you.

I haven’t got a clue, what does run-many do?

What about npm-run-all with the run-s command so they run sequentially?