Trigger cordova button programmatically

I have some problem with a simple issue in my unit tests for an Ionic 4 project using Cordova. Somewhere in my tests, I have to subscribe to the Android back button :

this.backButtonSubscription = this.platform.backButton.subscribeWithPriority(9999, () => {});

And I’d like have a 100% code coverage on my project, so I must find a way to trigger the backButton event, but I don’t find any solution yet. Do you have any idea ?

I said something totally wrong and just realized right now. I have to subscribe to the Android back button event in my code but I don’t don’t know how to trigger it in my unit tests.

you can use this.platform. registerBackButtonAction(fn, priority) .
Documentation link:

Unfortunately, registerBackButtonAction no longer exist in Ionic since v4…
Altough, would it allow me to trigger the event ?

Yup, you can trigger an event inside the registerBackButtonAction in v3. I am not sure about v4. I am using v3.

Mmmm, well good to know. It doesn’t resolve my issue but still give me some hope :grin:
Thanks anyway !