ionic-native-mocks
ionic-native-mocks copied to clipboard
[DOC] Add prod / dev switch scenario
Hi,
Thanks for these useful mocks.
Could you add in the main README an explanation about how we can disable mock in production mode ?
//AOT trick
let checkDevMode = false;
if (isDevMode()) {
checkDevMode = true;
}
const CameraConfiguration = (checkDevMode) ? { provide: Camera, useClass: CameraMock } : Camera;
providers: [
...,
CameraConfiguration,
...
]
I think this approach is better. You don't have to change it every time you build your app:
const isBrowser = document.URL.includes(‘https://’) || document.URL.includes(‘http://’);/*document.URL.startsWith(‘http’);
and then a bit lower in the provides :
(isBrowser ? {provide : Camera, useClass : CameraMock} : Camera),
(isBrowser ? {provide : ImagePicker, useClass : ImagePickerMock} : ImagePicker),
(isBrowser ? {provide : Geolocation, useClass : GeolocationMock} : Geolocation),
Thanks. I will add this to the Read Me shortly.
const isBrowser = document.URL.includes(‘https://’) || document.URL.includes(‘http://’);/*document.URL.startsWith(‘http’);
Your approach doesnt work i logged this and it always returned true . and ionic seems to be running in the localhost in a mobile device