Ionic jenkins ci e2e test cases

I want to run e2e tests for my ionic apps in jenkins.
However I did not manage to run the ionic cli in background without using tmux.

Locally / manually tmux works just fine. However in jenkins a script like this one does not work:

sh 'tmux new-session -d -s ionicServe'
sh 'tmux new-session -d -s e2e'
sh 'tmux send-keys -t ionicServe "ionic serve --nobrowser --nolivereload localhost" C-m'
sh 'tmux send-keys -t e2e "npm run e2ej" C-m'
sh 'tmux attach -t e2e'

It fails to attach with this error: terminal failed: not a terminal

  1. what is a proper way to handle the e2e cases in jenkins / run ionic cli / ionic serve in background
  2. if tmux really is the only viable approach how to make it work / fix my problem mentioned above?

Thanks a lot.