SDA-3833 (Update isDevEnv check) (#2070)

* SDA-3833 - Update isDevEnv check

* SDA-3833 - Update isDevEnv for unit tests
This commit is contained in:
Kiran Niranjan 2024-01-11 16:37:54 +05:30 committed by GitHub
parent d5647f0170
commit b862bd5561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Demo (Build &amp; Run)" type="NodeJSConfigurationType" application-parameters=". --url=file://$PROJECT_DIR$/src/demo/index.html" path-to-node="$PROJECT_DIR$/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron" working-dir="$PROJECT_DIR$">
<envs>
<env name="ELECTRON_DEV" value="true" />
<env name="ELECTRON_FORCE_IS_PACKAGED" value="true" />
<env name="ELECTRON_DEBUGGING" value="true" />
</envs>
<method v="2">

View File

@ -31,7 +31,7 @@
"postinstall": "electron-builder install-app-deps",
"start": "run-s compile browserify && cross-env ELECTRON_DEV=true electron .",
"test": "run-s lint test:unit",
"test:unit": "cross-env ELECTRON_QA=true jest --config jest-config.json --runInBand --detectOpenHandles",
"test:unit": "cross-env ELECTRON_FORCE_IS_PACKAGED=false ELECTRON_QA=true jest --config jest-config.json --runInBand --detectOpenHandles",
"unpacked-mac": "npm run prebuild && npm run test && ./node_modules/.bin/electron-builder build --mac",
"unpacked-win": "npm run prebuild && npm run test && node_modules\\.bin\\electron-builder build --win --x64"
},

View File

@ -7,6 +7,24 @@ jest.mock('electron-log');
jest.mock('../src/app/auto-update-handler', () => {
return {};
});
jest.mock('../src/common/env', () => {
return {
isWindowsOS: true,
isLinux: false,
isMac: false,
isDevEnv: true,
};
});
jest.mock('../src/common/logger', () => {
return {
logger: {
setLoggerWindow: jest.fn(),
error: jest.fn(),
info: jest.fn(),
},
};
});
describe('config', () => {
const configFileName: string = 'Symphony.config';

View File

@ -1,6 +1,5 @@
export const isDevEnv = process.env.ELECTRON_DEV
? process.env.ELECTRON_DEV.trim().toLowerCase() === 'true'
: false;
import { app } from 'electron';
export const isDevEnv = !app?.isPackaged;
export const isElectronQA = !!process.env.ELECTRON_QA;
export const isMac = process.platform === 'darwin';