Hello katsusuke,
It allows you to run tmate -S /tmp/tmate.sock display -p '#{tmate_num_clients}' to get the number of clients currently connected to the sesion.
However, for your use case, I would recommend using named session (see on
https://tmate.io), and foreground mode.
Using the following:
$ echo set tmate-api-key tmk-XXXX > ~/.tmate.conf
$ echo set tmate-foreground-restart 0 >> ~/.tmate.conf
$ tmate -n ci -F
You can then connect to
https://tmate.io/t/katsusuke/ci and access the terminal there. Once you close the shell, the tmate daemon would die, and your test would die too if nothing else is queued.
Let me know how it goes,
Nico