Why do you want it to run in the background on CI?
It should be ok to run the command just before the test:
ionic serve --nolivereload --nobrowser &
Your CI should kill the entire initiated process after it is completed ...
Update:
If your CI does not kill the called process, you can do something like this:
ionic serve --nolivereload --nobrowser & ionicpid=$! your_test_command_here kill -15 $ionicpid
It should work on CI if all these commands are in one task.
source share