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....')
}
}
}