Ionic native mocks best practices

with the new ionic native version 3 class based plugins and the ability to mock in the browser, what is the best way to use a mock?
and when done testing in the browser how would you go about removing the mock functionality when testing on a device?
i’v seen some great tutorials that show the usage, be it Paul Halliday or Joshua Morony videos in which they( or one of them ) suggests creating a script to automate removing of mock.

I’ve got my own idea of dealing with them by extending the base plugin class and checking if cordova is defined then calling the base class method with super.methodName
but I’m not sure if it would be best practice to leave them in for production?
what would be the cons of doing so, other then a slightly larger bundle?
is the checking of the windows cordova property not very reliable?

import { Camera, CameraOptions } from '@ionic-native/camera';

export class CameraMock extends Camera {
    getPicture(options: CameraOptions) {
        if ( !!(<any>window).cordova ) {
           return super.getPicture(options);
        } else {
            console.log('camera mock');
        return new Promise((resolve, reject) => {
            resolve( '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4MC....')

1 Like

It is not work for me. Could you share full source code of simple project?
My current way

@airsteo Sorry fo the late response. This was more of a question by me to know if it’s a good idea, not sure why it doesn’t work for you, did you add the class as a masked provider to the app module? Like in the linked videos

I’ve attached source files in this link Can’t recognize what you mean about masked provider… (

Sorry on my phone. By masked provider I meant .
{ useClass:camera, provide: CamraMock } in the ngModule,