Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: added overlap config dashboard options with env options (#7087
) * test: added tests Should add dashboard reporter options from environment and Should recover config options * feat: added function getOptionsFromEnv * type: added interface DasboardOptions * refactor: refactored names * refactor: reuse the interface DasboardOptions for the config storage * feat: added merging dashboard options with env options * test: fixed tests * test: fixed tests * fix: fixed merging dashboard options
- Loading branch information
Showing
5 changed files
with
114 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DasboardOptions } from './interfaces'; | ||
|
||
function parseBooleanVariable (value?: string): boolean { | ||
return value === 'false' || value === '0' ? false : !!value; | ||
} | ||
|
||
function parseNumber (value?: string): number | undefined { | ||
const parsed = value === void 0 ? Number.NaN : Number.parseInt(value, 10); | ||
|
||
if (Number.isNaN(parsed)) | ||
return void 0; | ||
|
||
return parsed; | ||
} | ||
|
||
export default function getEnvOptions (): DasboardOptions { | ||
return { | ||
url: process.env.TESTCAFE_DASHBOARD_URL, | ||
token: process.env.TESTCAFE_DASHBOARD_TOKEN, | ||
buildId: process.env.TESTCAFE_DASHBOARD_BUILD_ID, | ||
isLogEnabled: parseBooleanVariable(process.env.TESTCAFE_DASHBOARD_ENABLE_LOG), | ||
noScreenshotUpload: parseBooleanVariable(process.env.TESTCAFE_DASHBOARD_NO_SCREENSHOT_UPLOAD), | ||
noVideoUpload: parseBooleanVariable(process.env.TESTCAFE_DASHBOARD_NO_VIDEO_UPLOAD), | ||
responseTimeout: parseNumber(process.env.TESTCAFE_DASHBOARD_RESPONSE_TIMEOUT), | ||
requestRetryCount: parseNumber(process.env.TESTCAFE_DASHBOARD_REQUEST_RETRY_COUNT), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters