@azure/playwright 1.0.1-alpha.20251231.2 → 1.1.0-alpha.20260106.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -1
- package/dist/browser/common/entraIdAccessToken.js +1 -1
- package/dist/browser/common/entraIdAccessToken.js.map +1 -1
- package/dist/browser/common/messages.d.ts +9 -1
- package/dist/browser/common/messages.d.ts.map +1 -1
- package/dist/browser/common/messages.js +26 -18
- package/dist/browser/common/messages.js.map +1 -1
- package/dist/browser/core/playwrightService.js +1 -1
- package/dist/browser/core/playwrightService.js.map +1 -1
- package/dist/browser/reporter/playwrightReporter.d.ts.map +1 -1
- package/dist/browser/reporter/playwrightReporter.js +21 -1
- package/dist/browser/reporter/playwrightReporter.js.map +1 -1
- package/dist/browser/utils/utils.d.ts.map +1 -1
- package/dist/browser/utils/utils.js +3 -4
- package/dist/browser/utils/utils.js.map +1 -1
- package/dist/commonjs/common/entraIdAccessToken.js +1 -1
- package/dist/commonjs/common/entraIdAccessToken.js.map +1 -1
- package/dist/commonjs/common/messages.d.ts +9 -1
- package/dist/commonjs/common/messages.d.ts.map +1 -1
- package/dist/commonjs/common/messages.js +26 -18
- package/dist/commonjs/common/messages.js.map +1 -1
- package/dist/commonjs/core/playwrightService.js +1 -1
- package/dist/commonjs/core/playwrightService.js.map +1 -1
- package/dist/commonjs/reporter/playwrightReporter.d.ts.map +1 -1
- package/dist/commonjs/reporter/playwrightReporter.js +20 -0
- package/dist/commonjs/reporter/playwrightReporter.js.map +1 -1
- package/dist/commonjs/utils/utils.d.ts.map +1 -1
- package/dist/commonjs/utils/utils.js +3 -4
- package/dist/commonjs/utils/utils.js.map +1 -1
- package/dist/esm/common/entraIdAccessToken.js +1 -1
- package/dist/esm/common/entraIdAccessToken.js.map +1 -1
- package/dist/esm/common/messages.d.ts +9 -1
- package/dist/esm/common/messages.d.ts.map +1 -1
- package/dist/esm/common/messages.js +26 -18
- package/dist/esm/common/messages.js.map +1 -1
- package/dist/esm/core/playwrightService.js +1 -1
- package/dist/esm/core/playwrightService.js.map +1 -1
- package/dist/esm/reporter/playwrightReporter.d.ts.map +1 -1
- package/dist/esm/reporter/playwrightReporter.js +21 -1
- package/dist/esm/reporter/playwrightReporter.js.map +1 -1
- package/dist/esm/utils/utils.d.ts.map +1 -1
- package/dist/esm/utils/utils.js +3 -4
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/react-native/common/entraIdAccessToken.js +1 -1
- package/dist/react-native/common/entraIdAccessToken.js.map +1 -1
- package/dist/react-native/common/messages.d.ts +9 -1
- package/dist/react-native/common/messages.d.ts.map +1 -1
- package/dist/react-native/common/messages.js +26 -18
- package/dist/react-native/common/messages.js.map +1 -1
- package/dist/react-native/core/playwrightService.js +1 -1
- package/dist/react-native/core/playwrightService.js.map +1 -1
- package/dist/react-native/reporter/playwrightReporter.d.ts.map +1 -1
- package/dist/react-native/reporter/playwrightReporter.js +21 -1
- package/dist/react-native/reporter/playwrightReporter.js.map +1 -1
- package/dist/react-native/utils/utils.d.ts.map +1 -1
- package/dist/react-native/utils/utils.js +3 -4
- package/dist/react-native/utils/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -31,7 +31,6 @@ export const getPackageVersion = () => {
|
|
|
31
31
|
}
|
|
32
32
|
return "unknown-version";
|
|
33
33
|
};
|
|
34
|
-
// const playwrightServiceConfig = new PlaywrightServiceConfig();
|
|
35
34
|
export const exitWithFailureMessage = (error, errorDetails) => {
|
|
36
35
|
console.log();
|
|
37
36
|
if (error.formatWithErrorDetails && errorDetails) {
|
|
@@ -104,7 +103,7 @@ export const validateMptPAT = (validationFailureCallback) => {
|
|
|
104
103
|
const accessToken = getAccessToken();
|
|
105
104
|
const result = populateValuesFromServiceUrl();
|
|
106
105
|
if (!accessToken) {
|
|
107
|
-
validationFailureCallback(ServiceErrorMessageConstants.
|
|
106
|
+
validationFailureCallback(ServiceErrorMessageConstants.NO_AUTH_ERROR_PAT_TOKEN);
|
|
108
107
|
}
|
|
109
108
|
const claims = parseJwt(accessToken);
|
|
110
109
|
if (!claims.exp) {
|
|
@@ -134,7 +133,7 @@ const warnAboutTokenExpiry = (expirationTime, currentTime) => {
|
|
|
134
133
|
export const warnIfAccessTokenCloseToExpiry = () => {
|
|
135
134
|
const accessToken = getAccessToken();
|
|
136
135
|
if (!accessToken) {
|
|
137
|
-
throw new Error(ServiceErrorMessageConstants.
|
|
136
|
+
throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR_PAT_TOKEN.message);
|
|
138
137
|
}
|
|
139
138
|
const claims = parseJwt(accessToken);
|
|
140
139
|
const currentTime = Date.now();
|
|
@@ -150,7 +149,7 @@ export const fetchOrValidateAccessToken = async (credential) => {
|
|
|
150
149
|
}
|
|
151
150
|
const token = getAccessToken();
|
|
152
151
|
if (!token) {
|
|
153
|
-
throw new Error(ServiceErrorMessageConstants.
|
|
152
|
+
throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR_ENTRA_TOKEN.message);
|
|
154
153
|
}
|
|
155
154
|
return token;
|
|
156
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EACL,SAAS,EACT,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,M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E;IAChF,IAAI,CAAC;QACH,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;YAClD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAE9B,0FAA0F;QAC1F,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAErE,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACtB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,kDAAkD,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AccessTokenClaims,\n VersionInfo,\n JwtPayload,\n RunConfig,\n WorkspaceMetaData,\n} from \"../common/types.js\";\nimport {\n Constants,\n InternalEnvironmentVariables,\n ServiceEnvironmentVariable,\n RunConfigConstants,\n GitHubActionsConstants,\n} from \"../common/constants.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport { coreLogger } from \"../common/logger.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport process from \"node:process\";\nimport { randomUUID } from \"node:crypto\";\nimport { parseJwt } from \"./parseJwt.js\";\nimport { getPlaywrightVersion } from \"./getPlaywrightVersion.js\";\nimport { createEntraIdAccessToken } from \"../common/entraIdAccessToken.js\";\nimport { FullConfig } from \"@playwright/test\";\nimport { CI_PROVIDERS, CIInfo } from \"./cIInfoProvider.js\";\nimport { exec } from \"child_process\";\nimport { getPackageVersionFromFolder } from \"./getPackageVersion.js\";\nimport { readdirSync, statSync } from \"fs\";\nimport { join, relative } from \"path\";\nimport { UploadConstants } from \"../common/constants.js\";\n\n// Re-exporting for backward compatibility\nexport { getPlaywrightVersion } from \"./getPlaywrightVersion.js\";\nexport { parseJwt } from \"./parseJwt.js\";\n\nexport const getPackageVersion = (): string => {\n // hacky way to get package version\n // try from dist folder first (customer perspective)\n const distVersion = getPackageVersionFromFolder(\"../../../\");\n if (distVersion) {\n return distVersion;\n }\n // if not found, try from src folder (internal test suite)\n const srcVersion = getPackageVersionFromFolder(\"../../\");\n if (srcVersion) {\n return srcVersion;\n }\n return \"unknown-version\";\n};\n\n// const playwrightServiceConfig = new PlaywrightServiceConfig();\n\nexport const exitWithFailureMessage = (\n error: {\n key: string;\n message: string;\n formatWithErrorDetails?: (errorDetails: string) => string;\n },\n errorDetails?: string,\n): never => {\n console.log();\n\n if (error.formatWithErrorDetails && errorDetails) {\n console.error(error.formatWithErrorDetails(errorDetails));\n } else {\n console.error(error.message);\n }\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n};\n\nexport const throwErrorWithFailureMessage = (\n error: {\n key: string;\n message: string;\n formatWithErrorDetails?: (errorDetails: string) => string;\n },\n errorDetails?: string,\n): never => {\n console.log();\n\n const finalMessage =\n error.formatWithErrorDetails && errorDetails\n ? error.formatWithErrorDetails(errorDetails)\n : error.message;\n\n throw new Error(finalMessage);\n};\n\nexport const populateValuesFromServiceUrl = (): {\n region: string;\n domain: string;\n accountId: string;\n} | null => {\n // Service URL format: wss://<region>.api.playwright.microsoft.com/accounts/<workspace-id>/browsers\n const url = process.env[\"PLAYWRIGHT_SERVICE_URL\"]!;\n if (url) {\n const parts = url.split(\"/\");\n\n if (parts.length > 2) {\n const subdomainParts = parts[2]!.split(\".\");\n const region = subdomainParts.length > 0 ? subdomainParts[0] : null;\n const domain = subdomainParts.slice(2).join(\".\");\n const accountId = parts[4];\n\n return { region: region!, domain: domain!, accountId: accountId! };\n }\n }\n return null;\n};\n\nexport const getAccessToken = (): string | undefined => {\n return process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_ACCESS_TOKEN];\n};\n\nexport const getServiceBaseURL = (): string | undefined => {\n return process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL];\n};\n\nexport const isValidGuid = (guid: string | null | undefined): boolean => {\n if (!guid) {\n return false;\n }\n const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n return guidRegex.test(guid);\n};\n\nexport const getAndSetRunId = (): string => {\n const runId = randomUUID();\n process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID] = runId;\n return runId;\n};\n\nexport const getServiceWSEndpoint = (runId: string, os: string, apiVersion: string): string => {\n return `${getServiceBaseURL()}?runId=${encodeURIComponent(runId)}&os=${os}&api-version=${apiVersion}`;\n};\n\nexport const validateServiceUrl = (): void => {\n const serviceUrl = getServiceBaseURL();\n if (!serviceUrl) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n};\n\nexport const ValidateRunID = (runID: string): void => {\n const isValidRunID = isValidGuid(runID);\n if (!isValidRunID) {\n const errorMessage = ServiceErrorMessageConstants.INVALID_RUN_ID_FORMAT.message;\n throw new Error(errorMessage);\n }\n};\nexport const validateMptPAT = (\n validationFailureCallback: (error: { key: string; message: string }) => void,\n): void => {\n try {\n const accessToken = getAccessToken();\n const result = populateValuesFromServiceUrl();\n if (!accessToken) {\n validationFailureCallback(ServiceErrorMessageConstants.NO_AUTH_ERROR);\n }\n const claims = parseJwt<Partial<AccessTokenClaims>>(accessToken!);\n if (!claims.exp) {\n validationFailureCallback(ServiceErrorMessageConstants.INVALID_MPT_PAT_ERROR);\n }\n if (Date.now() >= claims.exp! * 1000) {\n validationFailureCallback(ServiceErrorMessageConstants.EXPIRED_MPT_PAT_ERROR);\n }\n if (result!.accountId !== claims!.pwid) {\n validationFailureCallback(ServiceErrorMessageConstants.WORKSPACE_MISMATCH_ERROR);\n }\n } catch (err) {\n coreLogger.error(err);\n exitWithFailureMessage(ServiceErrorMessageConstants.INVALID_MPT_PAT_ERROR);\n }\n};\nconst isTokenExpiringSoon = (expirationTime: number, currentTime: number): boolean => {\n return expirationTime * 1000 - currentTime <= Constants.SevenDaysInMS;\n};\n\nconst warnAboutTokenExpiry = (expirationTime: number, currentTime: number): void => {\n const daysToExpiration = Math.ceil((expirationTime * 1000 - currentTime) / Constants.OneDayInMS);\n const expirationDate = new Date(expirationTime * 1000).toLocaleDateString();\n const expirationWarning = `Warning: The access token used for this test run will expire in ${daysToExpiration} days on ${expirationDate}. Generate a new token from the portal to avoid failures. For a simpler, more secure solution, switch to Microsoft Entra ID and eliminate token management. https://learn.microsoft.com/entra/identity/`;\n console.warn(expirationWarning);\n};\n\nexport const warnIfAccessTokenCloseToExpiry = (): void => {\n const accessToken = getAccessToken();\n if (!accessToken) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);\n }\n const claims = parseJwt<JwtPayload>(accessToken!);\n const currentTime = Date.now();\n if (isTokenExpiringSoon(claims.exp!, currentTime)) {\n warnAboutTokenExpiry(claims.exp!, currentTime);\n }\n};\n\nexport const fetchOrValidateAccessToken = async (credential?: TokenCredential): Promise<string> => {\n const entraIdAccessToken = createEntraIdAccessToken(credential);\n // Fetch a token or refresh if needed in a single call\n if (entraIdAccessToken.doesEntraIdAccessTokenNeedRotation()) {\n await entraIdAccessToken.fetchEntraIdAccessToken();\n }\n const token = getAccessToken();\n if (!token) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);\n }\n return token;\n};\n\nexport const getVersionInfo = (version: string): VersionInfo => {\n const regex = /^(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?/;\n const match = version.match(regex);\n const versionInfo = {\n major: 0,\n minor: 0,\n patch: 0,\n };\n versionInfo.major = match && match[1] ? parseInt(match[1], 10) : 0;\n versionInfo.minor = match && match[2] ? parseInt(match[2], 10) : 0;\n versionInfo.patch = match && match[3] ? parseInt(match[3], 10) : 0;\n return versionInfo;\n};\n\nexport const validatePlaywrightVersion = (): void => {\n const minimumSupportedVersion = Constants.MinimumSupportedPlaywrightVersion;\n const installedVersion = getPlaywrightVersion();\n\n const minimumSupportedVersionInfo = getVersionInfo(minimumSupportedVersion);\n const installedVersionInfo = getVersionInfo(installedVersion);\n\n const isInstalledVersionGreater =\n installedVersionInfo.major > minimumSupportedVersionInfo.major ||\n (installedVersionInfo.major === minimumSupportedVersionInfo.major &&\n installedVersionInfo.minor >= minimumSupportedVersionInfo.minor);\n if (!isInstalledVersionGreater) {\n exitWithFailureMessage(ServiceErrorMessageConstants.INVALID_PLAYWRIGHT_VERSION_ERROR);\n }\n};\n\nexport const getTestRunConfig = (config: FullConfig): RunConfig => {\n const maxWorkers = config.workers || config.metadata.actualWorkers;\n const frameWorkVersion = config.version;\n\n const testRunConfig: RunConfig = {\n framework: {\n name: RunConfigConstants.TEST_FRAMEWORK_NAME,\n version: frameWorkVersion,\n runnerName: RunConfigConstants.TEST_FRAMEWORK_RUNNERNAME,\n },\n sdkLanguage: RunConfigConstants.TEST_SDK_LANGUAGE,\n maxWorkers: maxWorkers,\n };\n return testRunConfig;\n};\n\nexport function getTestRunApiUrl(): string {\n const result = populateValuesFromServiceUrl();\n const runId = process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID];\n\n if (!result?.region || !result?.domain || !result?.accountId) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n const baseUrl = `https://${result?.region}.reporting.api.${result?.domain}/playwrightworkspaces/${result?.accountId}/test-runs`;\n const url = runId ? `${baseUrl}/${runId}` : baseUrl;\n\n return `${url}?api-version=${Constants.LatestAPIVersion}`;\n}\n\nexport function isNullOrEmpty(str: string | null | undefined): boolean {\n return !str || str.trim() === \"\";\n}\n\nasync function runCommand(command: string): Promise<string> {\n return new Promise((resolve, reject) => {\n exec(command, (error, stdout, stderr) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(new Error(stderr));\n return;\n }\n resolve(stdout.trim());\n });\n });\n}\n\nexport async function getRunName(ciInfo: CIInfo): Promise<string> {\n if (\n ciInfo.providerName === CI_PROVIDERS.GITHUB &&\n process.env[\"GITHUB_EVENT_NAME\"] === \"pull_request\"\n ) {\n const prNumber: string = `${process.env[\"GITHUB_REF_NAME\"]?.split(\"/\")[0]}`;\n const prLink: string = `${process.env[\"GITHUB_REPOSITORY\"]}/pull/${prNumber}`;\n return `PR# ${prNumber} on Repo: ${process.env[\"GITHUB_REPOSITORY\"]} (${prLink})`;\n }\n\n try {\n const gitVersion = await runCommand(GitHubActionsConstants.GIT_VERSION_COMMAND);\n if (isNullOrEmpty(gitVersion)) {\n throw new Error(\"Git is not installed on the machine\");\n }\n const isInsideWorkTree = await runCommand(GitHubActionsConstants.GIT_REV_PARSE);\n if (isInsideWorkTree !== \"true\") {\n throw new Error(\"Not inside a git repository\");\n }\n const gitCommitMessage = await runCommand(GitHubActionsConstants.GIT_COMMIT_MESSAGE_COMMAND);\n return gitCommitMessage;\n } catch (err) {\n coreLogger.error(`Error in getting git commit message: ${err}.`);\n return \"\";\n }\n}\n\nexport function extractErrorMessage(responseBody: string): string {\n if (!responseBody) {\n return \"\";\n }\n\n try {\n const errorResponse = JSON.parse(responseBody);\n if (errorResponse.error && errorResponse.error.message) {\n return errorResponse.error.message;\n }\n return responseBody;\n } catch (e) {\n return responseBody;\n }\n}\n\nexport function getWorkspaceMetaDataApiUrl(): string {\n const result = populateValuesFromServiceUrl();\n\n if (!result?.region || !result?.domain || !result?.accountId) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n const baseUrl = `https://${result?.region}.api.${result?.domain}/playwrightworkspaces/${result?.accountId}`;\n\n return `${baseUrl}?api-version=${Constants.LatestAPIVersion}`;\n}\n\nexport function getHtmlReporterOutputFolder(config: FullConfig | undefined): string {\n const defaultFolder = \"playwright-report\";\n\n if (!config?.reporter) {\n return defaultFolder;\n }\n\n for (const reporter of config.reporter) {\n if (Array.isArray(reporter)) {\n const [reporterName, options] = reporter;\n if (reporterName === \"html\" && options && typeof options === \"object\") {\n return (options as any).outputFolder || defaultFolder;\n }\n } else if (typeof reporter === \"string\" && reporter === \"html\") {\n return defaultFolder;\n }\n }\n\n return defaultFolder;\n}\n\nexport function getContentType(filePath: string): string {\n const ext = filePath.toLowerCase().split(\".\").pop();\n\n const contentTypes: { [key: string]: string } = {\n html: \"text/html\",\n css: \"text/css\",\n js: \"application/javascript\",\n json: \"application/json\",\n png: \"image/png\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n svg: \"image/svg+xml\",\n ico: \"image/x-icon\",\n txt: \"text/plain\",\n ttf: \"font/ttf\",\n woff: \"font/woff\",\n woff2: \"font/woff2\",\n webmanifest: \"application/manifest+json\",\n map: \"application/json\",\n xml: \"application/xml\",\n pdf: \"application/pdf\",\n zip: \"application/zip\",\n };\n\n return contentTypes[ext || \"\"] || \"application/octet-stream\";\n}\n\nexport function calculateOptimalConcurrency(files: Array<{ size: number }>): number {\n const totalFiles = files.length;\n const totalSize = files.reduce((sum, f) => sum + f.size, 0);\n const avgFileSize = totalSize / totalFiles;\n\n let optimalConcurrency: number;\n\n if (totalFiles <= 10) {\n optimalConcurrency = Math.min(totalFiles, 10);\n } else if (avgFileSize < UploadConstants.SMALL_FILE_THRESHOLD) {\n optimalConcurrency = Math.min(\n UploadConstants.MAX_CONCURRENCY,\n Math.max(UploadConstants.BASE_CONCURRENCY, totalFiles / 50),\n );\n } else if (totalFiles > 1000) {\n optimalConcurrency = Math.min(\n UploadConstants.MAX_CONCURRENCY,\n UploadConstants.BASE_CONCURRENCY + Math.floor(totalFiles / 200),\n );\n } else {\n optimalConcurrency = Math.min(\n UploadConstants.MAX_CONCURRENCY,\n UploadConstants.BASE_CONCURRENCY,\n );\n }\n\n return Math.floor(optimalConcurrency);\n}\n\nexport function collectAllFiles(\n folderPath: string,\n basePath: string,\n runIdFolderPrefix?: string,\n): Array<{\n fullPath: string;\n relativePath: string;\n size: number;\n contentType: string;\n}> {\n const files: Array<{\n fullPath: string;\n relativePath: string;\n size: number;\n contentType: string;\n }> = [];\n\n const stack = [folderPath];\n\n while (stack.length > 0) {\n const currentPath = stack.pop()!;\n\n try {\n const items = readdirSync(currentPath);\n\n for (const item of items) {\n const itemPath = join(currentPath, item);\n const stats = statSync(itemPath);\n\n if (stats.isDirectory()) {\n stack.push(itemPath);\n } else {\n let relativePath = relative(basePath, itemPath).split(\"\\\\\").join(\"/\");\n\n if (runIdFolderPrefix) {\n relativePath = `${runIdFolderPrefix}/${relativePath}`;\n }\n\n files.push({\n fullPath: itemPath,\n relativePath,\n size: stats.size,\n contentType: getContentType(itemPath),\n });\n }\n }\n } catch (error) {\n continue;\n }\n }\n\n return files;\n}\n\nexport function getPortalTestRunUrl(workspaceMetadata: WorkspaceMetaData | null): string {\n const { subscriptionId, resourceId, name } = workspaceMetadata ?? {};\n if (!subscriptionId || !resourceId || !name) {\n throw new Error(\n \"Missing required workspace metadata: subscriptionId, resourceId, and name are required\",\n );\n }\n\n // Extract resource group from resourceId\n const resourceIdParts = resourceId.split(\"/\");\n const resourceGroupIndex = resourceIdParts.findIndex(\n (part) => part.toLowerCase() === \"resourcegroups\",\n );\n\n if (resourceGroupIndex === -1 || resourceGroupIndex + 1 >= resourceIdParts.length) {\n throw new Error(\"Invalid resourceId format: could not extract resource group name\");\n }\n\n const resourceGroupName = resourceIdParts[resourceGroupIndex + 1];\n return `https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/${encodeURIComponent(subscriptionId)}/resourceGroups/${encodeURIComponent(resourceGroupName)}/providers/Microsoft.LoadTestService/playwrightWorkspaces/${encodeURIComponent(name)}/TestRuns`;\n}\n\nexport const getStorageAccountNameFromUri = (storageUri: string): string | null => {\n try {\n if (!storageUri || typeof storageUri !== \"string\") {\n return null;\n }\n\n const url = new URL(storageUri);\n const hostname = url.hostname;\n\n // Extract storage account name from hostname pattern: {accountname}.blob.core.windows.net\n const match = hostname.match(/^([^.]+)\\.blob\\.core\\.windows\\.net$/i);\n\n if (match && match[1]) {\n return match[1];\n }\n\n return null;\n } catch (error) {\n console.warn(\"Failed to extract storage account name from URI:\", storageUri, error);\n return null;\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EACL,SAAS,EACT,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAU,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,0CAA0C;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAA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AE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,kDAAkD,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AccessTokenClaims,\n VersionInfo,\n JwtPayload,\n RunConfig,\n WorkspaceMetaData,\n} from \"../common/types.js\";\nimport {\n Constants,\n InternalEnvironmentVariables,\n ServiceEnvironmentVariable,\n RunConfigConstants,\n GitHubActionsConstants,\n} from \"../common/constants.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport { coreLogger } from \"../common/logger.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport process from \"node:process\";\nimport { randomUUID } from \"node:crypto\";\nimport { parseJwt } from \"./parseJwt.js\";\nimport { getPlaywrightVersion } from \"./getPlaywrightVersion.js\";\nimport { createEntraIdAccessToken } from \"../common/entraIdAccessToken.js\";\nimport { FullConfig } from \"@playwright/test\";\nimport { CI_PROVIDERS, CIInfo } from \"./cIInfoProvider.js\";\nimport { exec } from \"child_process\";\nimport { getPackageVersionFromFolder } from \"./getPackageVersion.js\";\nimport { readdirSync, statSync } from \"fs\";\nimport { join, relative } from \"path\";\nimport { UploadConstants } from \"../common/constants.js\";\n\n// Re-exporting for backward compatibility\nexport { getPlaywrightVersion } from \"./getPlaywrightVersion.js\";\nexport { parseJwt } from \"./parseJwt.js\";\n\nexport const getPackageVersion = (): string => {\n // hacky way to get package version\n // try from dist folder first (customer perspective)\n const distVersion = getPackageVersionFromFolder(\"../../../\");\n if (distVersion) {\n return distVersion;\n }\n // if not found, try from src folder (internal test suite)\n const srcVersion = getPackageVersionFromFolder(\"../../\");\n if (srcVersion) {\n return srcVersion;\n }\n return \"unknown-version\";\n};\n\nexport const exitWithFailureMessage = (\n error: {\n key: string;\n message: string;\n formatWithErrorDetails?: (errorDetails: string) => string;\n },\n errorDetails?: string,\n): never => {\n console.log();\n\n if (error.formatWithErrorDetails && errorDetails) {\n console.error(error.formatWithErrorDetails(errorDetails));\n } else {\n console.error(error.message);\n }\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n};\n\nexport const throwErrorWithFailureMessage = (\n error: {\n key: string;\n message: string;\n formatWithErrorDetails?: (errorDetails: string) => string;\n },\n errorDetails?: string,\n): never => {\n console.log();\n\n const finalMessage =\n error.formatWithErrorDetails && errorDetails\n ? error.formatWithErrorDetails(errorDetails)\n : error.message;\n\n throw new Error(finalMessage);\n};\n\nexport const populateValuesFromServiceUrl = (): {\n region: string;\n domain: string;\n accountId: string;\n} | null => {\n // Service URL format: wss://<region>.api.playwright.microsoft.com/accounts/<workspace-id>/browsers\n const url = process.env[\"PLAYWRIGHT_SERVICE_URL\"]!;\n if (url) {\n const parts = url.split(\"/\");\n\n if (parts.length > 2) {\n const subdomainParts = parts[2]!.split(\".\");\n const region = subdomainParts.length > 0 ? subdomainParts[0] : null;\n const domain = subdomainParts.slice(2).join(\".\");\n const accountId = parts[4];\n\n return { region: region!, domain: domain!, accountId: accountId! };\n }\n }\n return null;\n};\n\nexport const getAccessToken = (): string | undefined => {\n return process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_ACCESS_TOKEN];\n};\n\nexport const getServiceBaseURL = (): string | undefined => {\n return process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL];\n};\n\nexport const isValidGuid = (guid: string | null | undefined): boolean => {\n if (!guid) {\n return false;\n }\n const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n return guidRegex.test(guid);\n};\n\nexport const getAndSetRunId = (): string => {\n const runId = randomUUID();\n process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID] = runId;\n return runId;\n};\n\nexport const getServiceWSEndpoint = (runId: string, os: string, apiVersion: string): string => {\n return `${getServiceBaseURL()}?runId=${encodeURIComponent(runId)}&os=${os}&api-version=${apiVersion}`;\n};\n\nexport const validateServiceUrl = (): void => {\n const serviceUrl = getServiceBaseURL();\n if (!serviceUrl) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n};\n\nexport const ValidateRunID = (runID: string): void => {\n const isValidRunID = isValidGuid(runID);\n if (!isValidRunID) {\n const errorMessage = ServiceErrorMessageConstants.INVALID_RUN_ID_FORMAT.message;\n throw new Error(errorMessage);\n }\n};\nexport const validateMptPAT = (\n validationFailureCallback: (error: { key: string; message: string }) => void,\n): void => {\n try {\n const accessToken = getAccessToken();\n const result = populateValuesFromServiceUrl();\n if (!accessToken) {\n validationFailureCallback(ServiceErrorMessageConstants.NO_AUTH_ERROR_PAT_TOKEN);\n }\n const claims = parseJwt<Partial<AccessTokenClaims>>(accessToken!);\n if (!claims.exp) {\n validationFailureCallback(ServiceErrorMessageConstants.INVALID_MPT_PAT_ERROR);\n }\n if (Date.now() >= claims.exp! * 1000) {\n validationFailureCallback(ServiceErrorMessageConstants.EXPIRED_MPT_PAT_ERROR);\n }\n if (result!.accountId !== claims!.pwid) {\n validationFailureCallback(ServiceErrorMessageConstants.WORKSPACE_MISMATCH_ERROR);\n }\n } catch (err) {\n coreLogger.error(err);\n exitWithFailureMessage(ServiceErrorMessageConstants.INVALID_MPT_PAT_ERROR);\n }\n};\nconst isTokenExpiringSoon = (expirationTime: number, currentTime: number): boolean => {\n return expirationTime * 1000 - currentTime <= Constants.SevenDaysInMS;\n};\n\nconst warnAboutTokenExpiry = (expirationTime: number, currentTime: number): void => {\n const daysToExpiration = Math.ceil((expirationTime * 1000 - currentTime) / Constants.OneDayInMS);\n const expirationDate = new Date(expirationTime * 1000).toLocaleDateString();\n const expirationWarning = `Warning: The access token used for this test run will expire in ${daysToExpiration} days on ${expirationDate}. Generate a new token from the portal to avoid failures. For a simpler, more secure solution, switch to Microsoft Entra ID and eliminate token management. https://learn.microsoft.com/entra/identity/`;\n console.warn(expirationWarning);\n};\n\nexport const warnIfAccessTokenCloseToExpiry = (): void => {\n const accessToken = getAccessToken();\n if (!accessToken) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR_PAT_TOKEN.message);\n }\n const claims = parseJwt<JwtPayload>(accessToken!);\n const currentTime = Date.now();\n if (isTokenExpiringSoon(claims.exp!, currentTime)) {\n warnAboutTokenExpiry(claims.exp!, currentTime);\n }\n};\n\nexport const fetchOrValidateAccessToken = async (credential?: TokenCredential): Promise<string> => {\n const entraIdAccessToken = createEntraIdAccessToken(credential);\n // Fetch a token or refresh if needed in a single call\n if (entraIdAccessToken.doesEntraIdAccessTokenNeedRotation()) {\n await entraIdAccessToken.fetchEntraIdAccessToken();\n }\n const token = getAccessToken();\n if (!token) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR_ENTRA_TOKEN.message);\n }\n return token;\n};\n\nexport const getVersionInfo = (version: string): VersionInfo => {\n const regex = /^(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?/;\n const match = version.match(regex);\n const versionInfo = {\n major: 0,\n minor: 0,\n patch: 0,\n };\n versionInfo.major = match && match[1] ? parseInt(match[1], 10) : 0;\n versionInfo.minor = match && match[2] ? parseInt(match[2], 10) : 0;\n versionInfo.patch = match && match[3] ? parseInt(match[3], 10) : 0;\n return versionInfo;\n};\n\nexport const validatePlaywrightVersion = (): void => {\n const minimumSupportedVersion = Constants.MinimumSupportedPlaywrightVersion;\n const installedVersion = getPlaywrightVersion();\n\n const minimumSupportedVersionInfo = getVersionInfo(minimumSupportedVersion);\n const installedVersionInfo = getVersionInfo(installedVersion);\n\n const isInstalledVersionGreater =\n installedVersionInfo.major > minimumSupportedVersionInfo.major ||\n (installedVersionInfo.major === minimumSupportedVersionInfo.major &&\n installedVersionInfo.minor >= minimumSupportedVersionInfo.minor);\n if (!isInstalledVersionGreater) {\n exitWithFailureMessage(ServiceErrorMessageConstants.INVALID_PLAYWRIGHT_VERSION_ERROR);\n }\n};\n\nexport const getTestRunConfig = (config: FullConfig): RunConfig => {\n const maxWorkers = config.workers || config.metadata.actualWorkers;\n const frameWorkVersion = config.version;\n\n const testRunConfig: RunConfig = {\n framework: {\n name: RunConfigConstants.TEST_FRAMEWORK_NAME,\n version: frameWorkVersion,\n runnerName: RunConfigConstants.TEST_FRAMEWORK_RUNNERNAME,\n },\n sdkLanguage: RunConfigConstants.TEST_SDK_LANGUAGE,\n maxWorkers: maxWorkers,\n };\n return testRunConfig;\n};\n\nexport function getTestRunApiUrl(): string {\n const result = populateValuesFromServiceUrl();\n const runId = process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID];\n\n if (!result?.region || !result?.domain || !result?.accountId) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n const baseUrl = `https://${result?.region}.reporting.api.${result?.domain}/playwrightworkspaces/${result?.accountId}/test-runs`;\n const url = runId ? `${baseUrl}/${runId}` : baseUrl;\n\n return `${url}?api-version=${Constants.LatestAPIVersion}`;\n}\n\nexport function isNullOrEmpty(str: string | null | undefined): boolean {\n return !str || str.trim() === \"\";\n}\n\nasync function runCommand(command: string): Promise<string> {\n return new Promise((resolve, reject) => {\n exec(command, (error, stdout, stderr) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(new Error(stderr));\n return;\n }\n resolve(stdout.trim());\n });\n });\n}\n\nexport async function getRunName(ciInfo: CIInfo): Promise<string> {\n if (\n ciInfo.providerName === CI_PROVIDERS.GITHUB &&\n process.env[\"GITHUB_EVENT_NAME\"] === \"pull_request\"\n ) {\n const prNumber: string = `${process.env[\"GITHUB_REF_NAME\"]?.split(\"/\")[0]}`;\n const prLink: string = `${process.env[\"GITHUB_REPOSITORY\"]}/pull/${prNumber}`;\n return `PR# ${prNumber} on Repo: ${process.env[\"GITHUB_REPOSITORY\"]} (${prLink})`;\n }\n\n try {\n const gitVersion = await runCommand(GitHubActionsConstants.GIT_VERSION_COMMAND);\n if (isNullOrEmpty(gitVersion)) {\n throw new Error(\"Git is not installed on the machine\");\n }\n const isInsideWorkTree = await runCommand(GitHubActionsConstants.GIT_REV_PARSE);\n if (isInsideWorkTree !== \"true\") {\n throw new Error(\"Not inside a git repository\");\n }\n const gitCommitMessage = await runCommand(GitHubActionsConstants.GIT_COMMIT_MESSAGE_COMMAND);\n return gitCommitMessage;\n } catch (err) {\n coreLogger.error(`Error in getting git commit message: ${err}.`);\n return \"\";\n }\n}\n\nexport function extractErrorMessage(responseBody: string): string {\n if (!responseBody) {\n return \"\";\n }\n\n try {\n const errorResponse = JSON.parse(responseBody);\n if (errorResponse.error && errorResponse.error.message) {\n return errorResponse.error.message;\n }\n return responseBody;\n } catch (e) {\n return responseBody;\n }\n}\n\nexport function getWorkspaceMetaDataApiUrl(): string {\n const result = populateValuesFromServiceUrl();\n\n if (!result?.region || !result?.domain || !result?.accountId) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n const baseUrl = `https://${result?.region}.api.${result?.domain}/playwrightworkspaces/${result?.accountId}`;\n\n return `${baseUrl}?api-version=${Constants.LatestAPIVersion}`;\n}\n\nexport function getHtmlReporterOutputFolder(config: FullConfig | undefined): string {\n const defaultFolder = \"playwright-report\";\n\n if (!config?.reporter) {\n return defaultFolder;\n }\n\n for (const reporter of config.reporter) {\n if (Array.isArray(reporter)) {\n const [reporterName, options] = reporter;\n if (reporterName === \"html\" && options && typeof options === \"object\") {\n return (options as any).outputFolder || defaultFolder;\n }\n } else if (typeof reporter === \"string\" && reporter === \"html\") {\n return defaultFolder;\n }\n }\n\n return defaultFolder;\n}\n\nexport function getContentType(filePath: string): string {\n const ext = filePath.toLowerCase().split(\".\").pop();\n\n const contentTypes: { [key: string]: string } = {\n html: \"text/html\",\n css: \"text/css\",\n js: \"application/javascript\",\n json: \"application/json\",\n png: \"image/png\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n svg: \"image/svg+xml\",\n ico: \"image/x-icon\",\n txt: \"text/plain\",\n ttf: \"font/ttf\",\n woff: \"font/woff\",\n woff2: \"font/woff2\",\n webmanifest: \"application/manifest+json\",\n map: \"application/json\",\n xml: \"application/xml\",\n pdf: \"application/pdf\",\n zip: \"application/zip\",\n };\n\n return contentTypes[ext || \"\"] || \"application/octet-stream\";\n}\n\nexport function calculateOptimalConcurrency(files: Array<{ size: number }>): number {\n const totalFiles = files.length;\n const totalSize = files.reduce((sum, f) => sum + f.size, 0);\n const avgFileSize = totalSize / totalFiles;\n\n let optimalConcurrency: number;\n\n if (totalFiles <= 10) {\n optimalConcurrency = Math.min(totalFiles, 10);\n } else if (avgFileSize < UploadConstants.SMALL_FILE_THRESHOLD) {\n optimalConcurrency = Math.min(\n UploadConstants.MAX_CONCURRENCY,\n Math.max(UploadConstants.BASE_CONCURRENCY, totalFiles / 50),\n );\n } else if (totalFiles > 1000) {\n optimalConcurrency = Math.min(\n UploadConstants.MAX_CONCURRENCY,\n UploadConstants.BASE_CONCURRENCY + Math.floor(totalFiles / 200),\n );\n } else {\n optimalConcurrency = Math.min(\n UploadConstants.MAX_CONCURRENCY,\n UploadConstants.BASE_CONCURRENCY,\n );\n }\n\n return Math.floor(optimalConcurrency);\n}\n\nexport function collectAllFiles(\n folderPath: string,\n basePath: string,\n runIdFolderPrefix?: string,\n): Array<{\n fullPath: string;\n relativePath: string;\n size: number;\n contentType: string;\n}> {\n const files: Array<{\n fullPath: string;\n relativePath: string;\n size: number;\n contentType: string;\n }> = [];\n\n const stack = [folderPath];\n\n while (stack.length > 0) {\n const currentPath = stack.pop()!;\n\n try {\n const items = readdirSync(currentPath);\n\n for (const item of items) {\n const itemPath = join(currentPath, item);\n const stats = statSync(itemPath);\n\n if (stats.isDirectory()) {\n stack.push(itemPath);\n } else {\n let relativePath = relative(basePath, itemPath).split(\"\\\\\").join(\"/\");\n\n if (runIdFolderPrefix) {\n relativePath = `${runIdFolderPrefix}/${relativePath}`;\n }\n\n files.push({\n fullPath: itemPath,\n relativePath,\n size: stats.size,\n contentType: getContentType(itemPath),\n });\n }\n }\n } catch (error) {\n continue;\n }\n }\n\n return files;\n}\n\nexport function getPortalTestRunUrl(workspaceMetadata: WorkspaceMetaData | null): string {\n const { subscriptionId, resourceId, name } = workspaceMetadata ?? {};\n if (!subscriptionId || !resourceId || !name) {\n throw new Error(\n \"Missing required workspace metadata: subscriptionId, resourceId, and name are required\",\n );\n }\n\n // Extract resource group from resourceId\n const resourceIdParts = resourceId.split(\"/\");\n const resourceGroupIndex = resourceIdParts.findIndex(\n (part) => part.toLowerCase() === \"resourcegroups\",\n );\n\n if (resourceGroupIndex === -1 || resourceGroupIndex + 1 >= resourceIdParts.length) {\n throw new Error(\"Invalid resourceId format: could not extract resource group name\");\n }\n\n const resourceGroupName = resourceIdParts[resourceGroupIndex + 1];\n return `https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/${encodeURIComponent(subscriptionId)}/resourceGroups/${encodeURIComponent(resourceGroupName)}/providers/Microsoft.LoadTestService/playwrightWorkspaces/${encodeURIComponent(name)}/TestRuns`;\n}\n\nexport const getStorageAccountNameFromUri = (storageUri: string): string | null => {\n try {\n if (!storageUri || typeof storageUri !== \"string\") {\n return null;\n }\n\n const url = new URL(storageUri);\n const hostname = url.hostname;\n\n // Extract storage account name from hostname pattern: {accountname}.blob.core.windows.net\n const match = hostname.match(/^([^.]+)\\.blob\\.core\\.windows\\.net$/i);\n\n if (match && match[1]) {\n return match[1];\n }\n\n return null;\n } catch (error) {\n console.warn(\"Failed to extract storage account name from URI:\", storageUri, error);\n return null;\n }\n};\n"]}
|
|
@@ -46,7 +46,7 @@ class EntraIdAccessToken {
|
|
|
46
46
|
catch (err) {
|
|
47
47
|
logger_js_1.coreLogger.error(err);
|
|
48
48
|
process.env[constants_js_1.InternalEnvironmentVariables.MPT_SETUP_FATAL_ERROR] = "true";
|
|
49
|
-
throw new Error(messages_js_1.ServiceErrorMessageConstants.
|
|
49
|
+
throw new Error(messages_js_1.ServiceErrorMessageConstants.NO_AUTH_ERROR_ENTRA_TOKEN.message);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
doesEntraIdAccessTokenNeedRotation() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entraIdAccessToken.js","sourceRoot":"","sources":["../../../src/common/entraIdAccessToken.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAiGlC,4DAEC;AAhGD,2CAAyC;AACzC,iDAIwB;AAExB,sDAAgD;AAChD,+CAA6D;AAE7D,MAAa,kBAAkB;IACtB,KAAK,CAAU;IACd,gBAAgB,CAAU,CAAC,kBAAkB;IAC7C,WAAW,CAAmB;IAC9B,SAAS,GAAG,KAAK,CAAC;IAE1B,YAAY,UAA4B;QACtC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,oCAAoC,EAAE,CAAC;IAC9C,CAAC;IAEM,uBAAuB,GAAG,KAAK,IAAmB,EAAE;QACzD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,0CAA4B,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;QACjF,CAAC;QACD,IAAI,CAAC;YACH,sBAAU,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;YAClD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAY,CAAC,QAAQ,CAAC,0CAA2B,CAAC,KAAK,CAAC,CAAC;YACxF,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YACnD,CAAC;YACD,IAAI,WAAW,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;gBACrC,mHAAmH;gBACnH,sBAAU,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;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,UAA4B;IACnE,OAAO,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { coreLogger } from \"./logger.js\";\nimport {\n EntraIdAccessTokenConstants,\n InternalEnvironmentVariables,\n ServiceEnvironmentVariable,\n} from \"./constants.js\";\nimport type { AccessTokenClaims } from \"./types.js\";\nimport { parseJwt } from \"../utils/parseJwt.js\";\nimport { ServiceErrorMessageConstants } from \"./messages.js\";\n\nexport class EntraIdAccessToken {\n public token?: string;\n private _expiryTimestamp?: number; // in milliseconds\n private _credential?: TokenCredential;\n private _noOpFlag = false;\n\n constructor(credential?: TokenCredential) {\n this._credential = credential;\n if (!this._credential) {\n this._noOpFlag = true;\n return;\n }\n this.setEntraIdAccessTokenFromEnvironment();\n }\n\n public fetchEntraIdAccessToken = async (): Promise<void> => {\n if (this._noOpFlag) {\n throw new Error(ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);\n }\n try {\n coreLogger.info(\"Fetching entra id access token\");\n const accessToken = await this._credential!.getToken(EntraIdAccessTokenConstants.SCOPE);\n if (!accessToken) {\n throw new Error(\"Entra id access token is null\");\n }\n if (accessToken.token === this.token) {\n // azure identity library can fetch the same token again from cache. 10 mins before expiry, it allows token refresh\n coreLogger.info(\"Cached access token is returned, will be retried again.\");\n return;\n }\n this.token = accessToken.token;\n this._expiryTimestamp = accessToken.expiresOnTimestamp;\n process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_ACCESS_TOKEN] = this.token!;\n coreLogger.info(\"Entra id access token fetched and set in environment variable\");\n coreLogger.info(\n \"Entra id access token expiry:\",\n new Date(this._expiryTimestamp!).toISOString(),\n );\n return;\n } catch (err) {\n coreLogger.error(err);\n process.env[InternalEnvironmentVariables.MPT_SETUP_FATAL_ERROR] = \"true\";\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR_ENTRA_TOKEN.message);\n }\n };\n\n public doesEntraIdAccessTokenNeedRotation(): boolean {\n if (this._noOpFlag) {\n throw new Error(ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);\n }\n if (!this.token) {\n coreLogger.info(\"Entra id access token not found, needs rotation\");\n return true;\n }\n const lifetimeLeft = this._expiryTimestamp! - new Date().getTime();\n const doesEntraTokenRequireRotation =\n lifetimeLeft <\n EntraIdAccessTokenConstants.LIFETIME_LEFT_THRESHOLD_IN_MINUTES_FOR_ROTATION * 60 * 1000;\n coreLogger.info(\n \"Entra id access token requires rotation:\",\n doesEntraTokenRequireRotation ? \"Yes\" : \"No\",\n );\n return doesEntraTokenRequireRotation;\n }\n\n private setEntraIdAccessTokenFromEnvironment = (): void => {\n try {\n const token = process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_ACCESS_TOKEN];\n if (!token) {\n return;\n }\n const claims = parseJwt<Partial<AccessTokenClaims>>(token);\n if (claims.pwid) {\n return;\n } // mpt PAT\n const expiry = new Date(claims.exp! * 1000);\n this.token = token;\n this._expiryTimestamp = expiry.getTime();\n } catch (_) {\n return;\n }\n };\n}\n\nexport function createEntraIdAccessToken(credential?: TokenCredential): EntraIdAccessToken {\n return new EntraIdAccessToken(credential);\n}\n"]}
|
|
@@ -11,6 +11,10 @@ export declare const ServiceErrorMessageConstants: {
|
|
|
11
11
|
key: string;
|
|
12
12
|
message: string;
|
|
13
13
|
};
|
|
14
|
+
PLAYWRIGHT_VERSION_TOO_OLD_FOR_REPORTING: {
|
|
15
|
+
key: string;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
14
18
|
MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR: {
|
|
15
19
|
key: string;
|
|
16
20
|
message: string;
|
|
@@ -19,7 +23,11 @@ export declare const ServiceErrorMessageConstants: {
|
|
|
19
23
|
key: string;
|
|
20
24
|
message: string;
|
|
21
25
|
};
|
|
22
|
-
|
|
26
|
+
NO_AUTH_ERROR_PAT_TOKEN: {
|
|
27
|
+
key: string;
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
NO_AUTH_ERROR_ENTRA_TOKEN: {
|
|
23
31
|
key: string;
|
|
24
32
|
message: string;
|
|
25
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,4BAA4B
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CA0DE,MAAM,KAAG,MAAM;;;;;;;;;;;;;;;;;+CAkBf,MAAM,KAAG,MAAM;;;;;;;;;uDAWP,MAAM,KAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;kCA8BpC,MAAM,KAAG,MAAM;;;;;uCAMV,MAAM,KAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;6BA0BzB,MAAM,KAAG,MAAM;;;;;4CAKA,MAAM,aAAa,MAAM,UAAU,MAAM,KAAG,MAAM;;;;;iCAM7D,MAAM,KAAG,MAAM;;;;;+CAKD,MAAM,KAAG,MAAM;;;;;;;;;;CAYzD,CAAC"}
|
|
@@ -16,6 +16,10 @@ exports.ServiceErrorMessageConstants = {
|
|
|
16
16
|
key: "InvalidPlaywrightVersionError",
|
|
17
17
|
message: "The Playwright version you are using is not supported. See the list of supported versions at https://aka.ms/pww/docs/supported-versions.",
|
|
18
18
|
},
|
|
19
|
+
PLAYWRIGHT_VERSION_TOO_OLD_FOR_REPORTING: {
|
|
20
|
+
key: "PlaywrightVersionTooOldForReporting",
|
|
21
|
+
message: "To use the Playwright Workspaces reporting feature, you need Playwright version 1.57 or later installed. Update the Playwright package to a supported version and try again.",
|
|
22
|
+
},
|
|
19
23
|
MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR: {
|
|
20
24
|
key: "MultipleSetupFilePlaywrightVersionError",
|
|
21
25
|
message: "The Playwright version you are using does not support multiple setup/teardown files. Please update to Playwright version 1.49.0 or higher.",
|
|
@@ -24,26 +28,30 @@ exports.ServiceErrorMessageConstants = {
|
|
|
24
28
|
key: "InvalidAccessToken",
|
|
25
29
|
message: "The provided access token does not match the specified workspace URL. Please verify that both values are correct.",
|
|
26
30
|
},
|
|
27
|
-
|
|
28
|
-
key: "
|
|
29
|
-
message: "
|
|
31
|
+
NO_AUTH_ERROR_PAT_TOKEN: {
|
|
32
|
+
key: "NoAuthErrorPatToken",
|
|
33
|
+
message: "Please set PLAYWRIGHT_SERVICE_ACCESS_TOKEN env variable when using ACCESS_TOKEN authentication. For more information, see https://aka.ms/pww/docs/authentication",
|
|
34
|
+
},
|
|
35
|
+
NO_AUTH_ERROR_ENTRA_TOKEN: {
|
|
36
|
+
key: "NoAuthErrorEntraToken",
|
|
37
|
+
message: "Could not authenticate with the service. For more information, see https://aka.ms/pww/docs/authentication",
|
|
30
38
|
},
|
|
31
39
|
INVALID_MPT_PAT_ERROR: {
|
|
32
40
|
key: "InvalidMptPatError",
|
|
33
|
-
message: "The
|
|
41
|
+
message: "The PLAYWRIGHT_SERVICE_ACCESS_TOKEN provided is invalid. Please make sure to set a valid token.",
|
|
34
42
|
},
|
|
35
43
|
EXPIRED_MPT_PAT_ERROR: {
|
|
36
44
|
key: "ExpiredMptPatError",
|
|
37
|
-
message: "
|
|
45
|
+
message: "The PLAYWRIGHT_SERVICE_ACCESS_TOKEN provided has expired. Create a new token.",
|
|
38
46
|
},
|
|
39
47
|
NO_CRED_ENTRA_AUTH_ERROR: {
|
|
40
48
|
key: "NoCredEntraAuthError",
|
|
41
|
-
message: "
|
|
49
|
+
message: "Missing 'credential' parameter which is required when using ENTRA_ID authentication, Azure credential not provided. See https://aka.ms/pww/docs/authentication for more information.",
|
|
42
50
|
},
|
|
43
51
|
FAILED_TO_CREATE_TEST_RUN: {
|
|
44
52
|
key: "FailedToCreateTestRun",
|
|
45
|
-
message: "Failed to create the test run in the Playwright workspaces.
|
|
46
|
-
formatWithErrorDetails: (errorDetails) => `Failed to create the test run in the Playwright workspaces. Error: ${errorDetails}.
|
|
53
|
+
message: "Failed to create the test run in the Playwright workspaces. For more information, see https://aka.ms/pww/docs/troubleshooting",
|
|
54
|
+
formatWithErrorDetails: (errorDetails) => `Failed to create the test run in the Playwright workspaces. Error: ${errorDetails}. For more information, see https://aka.ms/pww/docs/troubleshooting`,
|
|
47
55
|
},
|
|
48
56
|
INVALID_PARAM_WITH_SERVICE_CONFIG: {
|
|
49
57
|
key: "InvalidParamWithServiceConfig",
|
|
@@ -68,8 +76,8 @@ exports.ServiceErrorMessageConstants = {
|
|
|
68
76
|
},
|
|
69
77
|
STORAGE_AUTHORIZATION_FAILED: {
|
|
70
78
|
key: "StorageAuthorizationFailed",
|
|
71
|
-
message: "The user is not authorized to perform this operation. Please make sure you have the Storage Blob Data Contributor role assigned to the storage account.
|
|
72
|
-
formatWithStorageAccount: (storageAccountName) => `The user is not authorized to perform this operation. Please make sure you have the Storage Blob Data Contributor role assigned to the storage account - ${storageAccountName}.
|
|
79
|
+
message: "The user is not authorized to perform this operation. Please make sure you have the Storage Blob Data Contributor role assigned to the storage account. For more information, see https://aka.ms/pww-reporting",
|
|
80
|
+
formatWithStorageAccount: (storageAccountName) => `The user is not authorized to perform this operation. Please make sure you have the Storage Blob Data Contributor role assigned to the storage account - ${storageAccountName}. For more information, see https://aka.ms/pww-reporting`,
|
|
73
81
|
},
|
|
74
82
|
UNABLE_TO_EXTRACT_WORKSPACE_ID: {
|
|
75
83
|
key: "UnableToExtractWorkspaceId",
|
|
@@ -77,11 +85,11 @@ exports.ServiceErrorMessageConstants = {
|
|
|
77
85
|
},
|
|
78
86
|
REPORTER_REQUIRES_ENTRA_AUTH: {
|
|
79
87
|
key: "ReporterRequiresEntraAuth",
|
|
80
|
-
message: "Playwright Workspaces Reporter can only be used with ENTRA_ID authentication.
|
|
88
|
+
message: "Playwright Workspaces Reporter can only be used with ENTRA_ID authentication. For more information, see https://aka.ms/pww/docs/authentication",
|
|
81
89
|
},
|
|
82
90
|
HTML_REPORTER_REQUIRED: {
|
|
83
91
|
key: "HtmlReporterRequired",
|
|
84
|
-
message: "Playwright Workspaces Reporter requires the 'html' reporter to be configured in your Playwright configuration. Please add the 'html' reporter before playwright workspace reporter to generate test reports that can be uploaded to Azure Storage. Example: reporter: [['html'], ['@azure/playwright/reporter']]",
|
|
92
|
+
message: "Playwright Workspaces Reporter requires the 'html' reporter to be configured in your Playwright configuration. Please add the 'html' reporter before playwright workspace reporter to generate test reports that can be uploaded to Azure Storage. Example: reporter: [['html'], ['@azure/playwright/reporter']]. For more information, see https://aka.ms/pww-reporting",
|
|
85
93
|
},
|
|
86
94
|
WORKSPACE_METADATA_FETCH_FAILED: {
|
|
87
95
|
key: "WorkspaceMetadataFetchFailed",
|
|
@@ -89,7 +97,7 @@ exports.ServiceErrorMessageConstants = {
|
|
|
89
97
|
},
|
|
90
98
|
WORKSPACE_REPORTING_DISABLED: {
|
|
91
99
|
key: "WorkspaceReportingDisabled",
|
|
92
|
-
message: "Playwright Workspaces reporting: DISABLED. Reporting is not enabled for the Playwright Workspace. To learn more about how to enable reporting and link a storage account,
|
|
100
|
+
message: "Playwright Workspaces reporting: DISABLED. Reporting is not enabled for the Playwright Workspace. To learn more about how to enable reporting and link a storage account, For more information, see https://aka.ms/pww-reporting",
|
|
93
101
|
},
|
|
94
102
|
UPLOAD_FAILED_FILES: {
|
|
95
103
|
key: "UploadFailedFiles",
|
|
@@ -99,7 +107,7 @@ exports.ServiceErrorMessageConstants = {
|
|
|
99
107
|
PLAYWRIGHT_TEST_REPORT_NOT_FOUND: {
|
|
100
108
|
key: "PlaywrightTestReportNotFound",
|
|
101
109
|
message: "Playwright test report not found",
|
|
102
|
-
formatWithFolder: (folderName) => `Playwright test report not found: ${folderName}`,
|
|
110
|
+
formatWithFolder: (folderName) => `Playwright test report not found: ${folderName}. For more information, see https://aka.ms/pww-reporting`,
|
|
103
111
|
},
|
|
104
112
|
REPORTING_ENABLED: {
|
|
105
113
|
key: "ReportingEnabled",
|
|
@@ -111,15 +119,15 @@ exports.ServiceErrorMessageConstants = {
|
|
|
111
119
|
},
|
|
112
120
|
REPORTING_STATUS_SUCCESS: {
|
|
113
121
|
key: "ReportingStatusSuccess",
|
|
114
|
-
message: "Reporting status: SUCCESS",
|
|
122
|
+
message: "Reporting upload status: SUCCESS",
|
|
115
123
|
},
|
|
116
124
|
REPORTING_STATUS_PARTIAL: {
|
|
117
125
|
key: "ReportingStatusPartial",
|
|
118
|
-
message: "Reporting status: Partially Uploaded",
|
|
126
|
+
message: "Reporting upload status: Partially Uploaded",
|
|
119
127
|
},
|
|
120
128
|
REPORTING_STATUS_FAILED: {
|
|
121
129
|
key: "ReportingStatusFailed",
|
|
122
|
-
message: "Reporting status: FAILED",
|
|
130
|
+
message: "Reporting upload status: FAILED",
|
|
123
131
|
},
|
|
124
132
|
TEST_REPORT_VIEW_URL: {
|
|
125
133
|
key: "TestReportViewUrl",
|
|
@@ -147,7 +155,7 @@ exports.ServiceErrorMessageConstants = {
|
|
|
147
155
|
},
|
|
148
156
|
REPORTER_REQUIRES_SERVICE_CONFIG: {
|
|
149
157
|
key: "ReporterRequiresServiceConfig",
|
|
150
|
-
message: "Playwright Workspaces Reporter requires the use of service configuration via createAzurePlaywrightConfig.",
|
|
158
|
+
message: "Playwright Workspaces Reporter requires the use of service configuration via createAzurePlaywrightConfig. For more information, see https://aka.ms/pww-reporting.",
|
|
151
159
|
},
|
|
152
160
|
};
|
|
153
161
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAErB,QAAA,4BAA4B,GAAG;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,wBAAwB;QAC7B,OAAO,EAAE,sCAAsC;KAChD;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EAAE,0BAA0B;KACpC;IACD,oBAAoB,EAAE;QACpB,GAAG,EAAE,mBAAmB;QACxB,OAAO,EAAE,wBAAwB;QACjC,aAAa,EAAE,CAAC,GAAW,EAAU,EAAE,CAAC,yBAAyB,GAAG,EAAE;KACvE;IACD,mBAAmB,EAAE;QACnB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,gCAAgC;QACzC,iBAAiB,EAAE,CAAC,cAAsB,EAAE,SAAiB,EAAE,MAAc,EAAU,EAAE,CACvF,4CAA4C,cAAc,wBAAwB,SAAS,aAAa,MAAM,EAAE;KACnH;IACD,gCAAgC,EAAE;QAChC,GAAG,EAAE,8BAA8B;QACnC,OAAO,EAAE,kCAAkC;QAC3C,eAAe,EAAE,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK;KAClD;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EAAE,0DAA0D;QACnE,sBAAsB,EAAE,CAAC,YAAoB,EAAU,EAAE,CACvD,qCAAqC,YAAY,iCAAiC;KACrF;IACD,yBAAyB,EAAE;QACzB,GAAG,EAAE,wBAAwB;QAC7B,OAAO,EAAE,wCAAwC;KAClD;IACD,gCAAgC,EAAE;QAChC,GAAG,EAAE,+BAA+B;QACpC,OAAO,EACL,2GAA2G;KAC9G;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const ServiceErrorMessageConstants = {\n NO_SERVICE_URL_ERROR: {\n key: \"NoServiceUrlError\",\n message:\n \"The value for the PLAYWRIGHT_SERVICE_URL variable is not set correctly. Please verify the URL and try again.\",\n },\n INVALID_GLOBAL_FUNCTION: {\n key: \"InvalidGlobalFunction\",\n message: \"File must export a single function.\",\n },\n INVALID_PLAYWRIGHT_VERSION_ERROR: {\n key: \"InvalidPlaywrightVersionError\",\n message:\n \"The Playwright version you are using is not supported. See the list of supported versions at https://aka.ms/pww/docs/supported-versions.\",\n },\n MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR: {\n key: \"MultipleSetupFilePlaywrightVersionError\",\n message:\n \"The Playwright version you are using does not support multiple setup/teardown files. Please update to Playwright version 1.49.0 or higher.\",\n },\n WORKSPACE_MISMATCH_ERROR: {\n key: \"InvalidAccessToken\",\n message:\n \"The provided access token does not match the specified workspace URL. Please verify that both values are correct.\",\n },\n NO_AUTH_ERROR: {\n key: \"NoAuthError\",\n message:\n \"Could not authenticate with the service. Please refer to https://aka.ms/pww/docs/authentication for more information.\",\n },\n INVALID_MPT_PAT_ERROR: {\n key: \"InvalidMptPatError\",\n message: \"The authentication token provided is invalid. Check the token and try again.\",\n },\n EXPIRED_MPT_PAT_ERROR: {\n key: \"ExpiredMptPatError\",\n message: \"Your authentication token has expired. Create a new token.\",\n },\n NO_CRED_ENTRA_AUTH_ERROR: {\n key: \"NoCredEntraAuthError\",\n message:\n \"Azure credentials not found when using Entra ID authentication. Please refer to https://aka.ms/pww/docs/authentication for more information.\",\n },\n FAILED_TO_CREATE_TEST_RUN: {\n key: \"FailedToCreateTestRun\",\n message:\n \"Failed to create the test run in the Playwright workspaces. Please refer to https://aka.ms/pww/docs/troubleshooting for more information.\",\n formatWithErrorDetails: (errorDetails: string): string =>\n `Failed to create the test run in the Playwright workspaces. Error: ${errorDetails}. Please refer to https://aka.ms/pww/docs/troubleshooting for more information.`,\n },\n INVALID_PARAM_WITH_SERVICE_CONFIG: {\n key: \"InvalidParamWithServiceConfig\",\n message: `Remove serviceAuth, runId, and runName from getConnectOptions when using createAzurePlaywrightConfig. Configure these options through createAzurePlaywrightConfig instead.`,\n },\n INVALID_RUN_ID_FORMAT: {\n key: \"InvalidRunIdFormat\",\n message: \"The Run ID must be a valid GUID format. Please provide a valid GUID for the Run ID.\",\n },\n INVALID_AUTH_TYPE_ERROR: {\n key: \"InvalidAuthTypeError\",\n message: \"Invalid authentication type specified. Please use either ENTRA_ID or ACCESS_TOKEN.\",\n },\n FAILED_TO_GET_WORKSPACE_DETAILS: {\n key: \"FailedToGetWorkspaceDetails\",\n message: \"Failed to retrieve workspace details from the Playwright service.\",\n formatWithErrorDetails: (errorDetails: string): string =>\n `Failed to retrieve workspace details from the Playwright service. Error: ${errorDetails}. Please verify your service URL and authentication credentials.`,\n },\n STORAGE_URI_NOT_FOUND: {\n key: \"StorageUriNotFound\",\n message: \"Storage Account is not linked with this Playwright Workspace.\",\n },\n STORAGE_AUTHORIZATION_FAILED: {\n key: \"StorageAuthorizationFailed\",\n message:\n \"The user is not authorized to perform this operation. Please make sure you have the Storage Blob Data Contributor role assigned to the storage account. Refer to https://aka.ms/pww-reporting\",\n formatWithStorageAccount: (storageAccountName: string): string =>\n `The user is not authorized to perform this operation. Please make sure you have the Storage Blob Data Contributor role assigned to the storage account - ${storageAccountName}. Refer to https://aka.ms/pww-reporting`,\n },\n UNABLE_TO_EXTRACT_WORKSPACE_ID: {\n key: \"UnableToExtractWorkspaceId\",\n message: \"Unable to extract workspace ID from service URL\",\n },\n REPORTER_REQUIRES_ENTRA_AUTH: {\n key: \"ReporterRequiresEntraAuth\",\n message:\n \"Playwright Workspaces Reporter can only be used with ENTRA_ID authentication. Please refer to https://aka.ms/pww/docs/authentication for more information.\",\n },\n HTML_REPORTER_REQUIRED: {\n key: \"HtmlReporterRequired\",\n message:\n \"Playwright Workspaces Reporter requires the 'html' reporter to be configured in your Playwright configuration. Please add the 'html' reporter before playwright workspace reporter to generate test reports that can be uploaded to Azure Storage. Example: reporter: [['html'], ['@azure/playwright/reporter']]\",\n },\n WORKSPACE_METADATA_FETCH_FAILED: {\n key: \"WorkspaceMetadataFetchFailed\",\n message:\n \"Failed to retrieve workspace configuration. Reporting will be disabled for this run. Please check your authentication credentials and service URL.\",\n },\n WORKSPACE_REPORTING_DISABLED: {\n key: \"WorkspaceReportingDisabled\",\n message:\n \"Playwright Workspaces reporting: DISABLED. Reporting is not enabled for the Playwright Workspace. To learn more about how to enable reporting and link a storage account, refer to https://aka.ms/pww-reporting \",\n },\n UPLOAD_FAILED_FILES: {\n key: \"UploadFailedFiles\",\n message: \"Upload failed: files could not be uploaded\",\n formatWithCount: (failed: number): string =>\n `Upload failed: ${failed} files could not be uploaded`,\n },\n PLAYWRIGHT_TEST_REPORT_NOT_FOUND: {\n key: \"PlaywrightTestReportNotFound\",\n message: \"Playwright test report not found\",\n formatWithFolder: (folderName: string): string =>\n `Playwright test report not found: ${folderName}`,\n },\n REPORTING_ENABLED: {\n key: \"ReportingEnabled\",\n message: \"Playwright Workspaces reporting: ENABLED\",\n },\n COLLECTING_ARTIFACTS: {\n key: \"CollectingArtifacts\",\n message: \"Collecting artifacts: screenshots, videos, traces.\",\n },\n REPORTING_STATUS_SUCCESS: {\n key: \"ReportingStatusSuccess\",\n message: \"Reporting status: SUCCESS\",\n },\n REPORTING_STATUS_PARTIAL: {\n key: \"ReportingStatusPartial\",\n message: \"Reporting status: Partially Uploaded\",\n },\n REPORTING_STATUS_FAILED: {\n key: \"ReportingStatusFailed\",\n message: \"Reporting status: FAILED\",\n },\n TEST_REPORT_VIEW_URL: {\n key: \"TestReportViewUrl\",\n message: \"Published report URL: \",\n formatWithUrl: (url: string): string => `Published report URL: ${url}`,\n },\n UPLOADING_ARTIFACTS: {\n key: \"UploadingArtifacts\",\n message: \"Uploading artifacts to storage\",\n formatWithDetails: (storageAccount: string, container: string, folder: string): string =>\n `Uploading artifacts to: storage account= ${storageAccount}, storage container= ${container}, folder= ${folder}`,\n },\n FAILED_TO_GET_WORKSPACE_METADATA: {\n key: \"FailedToGetWorkspaceMetadata\",\n message: \"Failed to get workspace metadata\",\n formatWithError: (error: string): string => error,\n },\n TEST_RUN_CREATION_FAILED: {\n key: \"TestRunCreationFailed\",\n message: \"Failed to create test run. Test execution will continue.\",\n formatWithErrorDetails: (errorDetails: string): string =>\n `Failed to create test run. Error: ${errorDetails}. Test execution will continue.`,\n },\n REPORTING_TEST_RUN_FAILED: {\n key: \"ReportingTestRunFailed\",\n message: \"Test run creation failed during setup.\",\n },\n REPORTER_REQUIRES_SERVICE_CONFIG: {\n key: \"ReporterRequiresServiceConfig\",\n message:\n \"Playwright Workspaces Reporter requires the use of service configuration via createAzurePlaywrightConfig.\",\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAErB,QAAA,4BAA4B,GAAG;IAC1C,oBAAoB,EAAE;QACpB,GAAG,EAAE,mBAAmB;QACxB,OAAO,EACL,8GAA8G;KACjH;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EAAE,qCAAqC;KAC/C;IACD,gCAAgC,EAAE;QAChC,GAAG,EAAE,+BAA+B;QACpC,OAAO,EACL,0IAA0I;KAC7I;IACD,wCAAwC,EAAE;QACxC,GAAG,EAAE,qCAAqC;QAC1C,OAAO,EACL,8KAA8K;KACjL;IACD,4CAA4C,EAAE;QAC5C,GAAG,EAAE,yCAAyC;QAC9C,OAAO,EACL,4IAA4I;KAC/I;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EACL,mHAAmH;KACtH;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,qBAAqB;QAC1B,OAAO,EACL,kKAAkK;KACrK;IACD,yBAAyB,EAAE;QACzB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EACL,2GAA2G;KAC9G;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EACL,iGAAiG;KACpG;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,+EAA+E;KACzF;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,sBAAsB;QAC3B,OAAO,EACL,sLAAsL;KACzL;IACD,yBAAyB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AoB,EAAU,EAAE,CACvD,qCAAqC,YAAY,iCAAiC;KACrF;IACD,yBAAyB,EAAE;QACzB,GAAG,EAAE,wBAAwB;QAC7B,OAAO,EAAE,wCAAwC;KAClD;IACD,gCAAgC,EAAE;QAChC,GAAG,EAAE,+BAA+B;QACpC,OAAO,EACL,mKAAmK;KACtK;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const ServiceErrorMessageConstants = {\n NO_SERVICE_URL_ERROR: {\n key: \"NoServiceUrlError\",\n message:\n \"The value for the PLAYWRIGHT_SERVICE_URL variable is not set correctly. Please verify the URL and try again.\",\n },\n INVALID_GLOBAL_FUNCTION: {\n key: \"InvalidGlobalFunction\",\n message: \"File must export a single function.\",\n },\n INVALID_PLAYWRIGHT_VERSION_ERROR: {\n key: \"InvalidPlaywrightVersionError\",\n message:\n \"The Playwright version you are using is not supported. See the list of supported versions at https://aka.ms/pww/docs/supported-versions.\",\n },\n PLAYWRIGHT_VERSION_TOO_OLD_FOR_REPORTING: {\n key: \"PlaywrightVersionTooOldForReporting\",\n message:\n \"To use the Playwright Workspaces reporting feature, you need Playwright version 1.57 or later installed. Update the Playwright package to a supported version and try again.\",\n },\n MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR: {\n key: \"MultipleSetupFilePlaywrightVersionError\",\n message:\n \"The Playwright version you are using does not support multiple setup/teardown files. Please update to Playwright version 1.49.0 or higher.\",\n },\n WORKSPACE_MISMATCH_ERROR: {\n key: \"InvalidAccessToken\",\n message:\n \"The provided access token does not match the specified workspace URL. Please verify that both values are correct.\",\n },\n NO_AUTH_ERROR_PAT_TOKEN: {\n key: \"NoAuthErrorPatToken\",\n message:\n \"Please set PLAYWRIGHT_SERVICE_ACCESS_TOKEN env variable when using ACCESS_TOKEN authentication. For more information, see https://aka.ms/pww/docs/authentication\",\n },\n NO_AUTH_ERROR_ENTRA_TOKEN: {\n key: \"NoAuthErrorEntraToken\",\n message:\n \"Could not authenticate with the service. For more information, see https://aka.ms/pww/docs/authentication\",\n },\n INVALID_MPT_PAT_ERROR: {\n key: \"InvalidMptPatError\",\n message:\n \"The PLAYWRIGHT_SERVICE_ACCESS_TOKEN provided is invalid. Please make sure to set a valid token.\",\n },\n EXPIRED_MPT_PAT_ERROR: {\n key: \"ExpiredMptPatError\",\n message: \"The PLAYWRIGHT_SERVICE_ACCESS_TOKEN provided has expired. Create a new token.\",\n },\n NO_CRED_ENTRA_AUTH_ERROR: {\n key: \"NoCredEntraAuthError\",\n message:\n \"Missing 'credential' parameter which is required when using ENTRA_ID authentication, Azure credential not provided. See https://aka.ms/pww/docs/authentication for more information.\",\n },\n FAILED_TO_CREATE_TEST_RUN: {\n key: \"FailedToCreateTestRun\",\n message:\n \"Failed to create the test run in the Playwright workspaces. For more information, see https://aka.ms/pww/docs/troubleshooting\",\n formatWithErrorDetails: (errorDetails: string): string =>\n `Failed to create the test run in the Playwright workspaces. Error: ${errorDetails}. For more information, see https://aka.ms/pww/docs/troubleshooting`,\n },\n INVALID_PARAM_WITH_SERVICE_CONFIG: {\n key: \"InvalidParamWithServiceConfig\",\n message: `Remove serviceAuth, runId, and runName from getConnectOptions when using createAzurePlaywrightConfig. Configure these options through createAzurePlaywrightConfig instead.`,\n },\n INVALID_RUN_ID_FORMAT: {\n key: \"InvalidRunIdFormat\",\n message: \"The Run ID must be a valid GUID format. Please provide a valid GUID for the Run ID.\",\n },\n INVALID_AUTH_TYPE_ERROR: {\n key: \"InvalidAuthTypeError\",\n message: \"Invalid authentication type specified. Please use either ENTRA_ID or ACCESS_TOKEN.\",\n },\n FAILED_TO_GET_WORKSPACE_DETAILS: {\n key: \"FailedToGetWorkspaceDetails\",\n message: \"Failed to retrieve workspace details from the Playwright service.\",\n formatWithErrorDetails: (errorDetails: string): string =>\n `Failed to retrieve workspace details from the Playwright service. Error: ${errorDetails}. Please verify your service URL and authentication credentials.`,\n },\n STORAGE_URI_NOT_FOUND: {\n key: \"StorageUriNotFound\",\n message: \"Storage Account is not linked with this Playwright Workspace.\",\n },\n STORAGE_AUTHORIZATION_FAILED: {\n key: \"StorageAuthorizationFailed\",\n message:\n \"The user is not authorized to perform this operation. Please make sure you have the Storage Blob Data Contributor role assigned to the storage account. For more information, see https://aka.ms/pww-reporting\",\n formatWithStorageAccount: (storageAccountName: string): string =>\n `The user is not authorized to perform this operation. Please make sure you have the Storage Blob Data Contributor role assigned to the storage account - ${storageAccountName}. For more information, see https://aka.ms/pww-reporting`,\n },\n UNABLE_TO_EXTRACT_WORKSPACE_ID: {\n key: \"UnableToExtractWorkspaceId\",\n message: \"Unable to extract workspace ID from service URL\",\n },\n REPORTER_REQUIRES_ENTRA_AUTH: {\n key: \"ReporterRequiresEntraAuth\",\n message:\n \"Playwright Workspaces Reporter can only be used with ENTRA_ID authentication. For more information, see https://aka.ms/pww/docs/authentication\",\n },\n HTML_REPORTER_REQUIRED: {\n key: \"HtmlReporterRequired\",\n message:\n \"Playwright Workspaces Reporter requires the 'html' reporter to be configured in your Playwright configuration. Please add the 'html' reporter before playwright workspace reporter to generate test reports that can be uploaded to Azure Storage. Example: reporter: [['html'], ['@azure/playwright/reporter']]. For more information, see https://aka.ms/pww-reporting\",\n },\n WORKSPACE_METADATA_FETCH_FAILED: {\n key: \"WorkspaceMetadataFetchFailed\",\n message:\n \"Failed to retrieve workspace configuration. Reporting will be disabled for this run. Please check your authentication credentials and service URL.\",\n },\n WORKSPACE_REPORTING_DISABLED: {\n key: \"WorkspaceReportingDisabled\",\n message:\n \"Playwright Workspaces reporting: DISABLED. Reporting is not enabled for the Playwright Workspace. To learn more about how to enable reporting and link a storage account, For more information, see https://aka.ms/pww-reporting\",\n },\n UPLOAD_FAILED_FILES: {\n key: \"UploadFailedFiles\",\n message: \"Upload failed: files could not be uploaded\",\n formatWithCount: (failed: number): string =>\n `Upload failed: ${failed} files could not be uploaded`,\n },\n PLAYWRIGHT_TEST_REPORT_NOT_FOUND: {\n key: \"PlaywrightTestReportNotFound\",\n message: \"Playwright test report not found\",\n formatWithFolder: (folderName: string): string =>\n `Playwright test report not found: ${folderName}. For more information, see https://aka.ms/pww-reporting`,\n },\n REPORTING_ENABLED: {\n key: \"ReportingEnabled\",\n message: \"Playwright Workspaces reporting: ENABLED\",\n },\n COLLECTING_ARTIFACTS: {\n key: \"CollectingArtifacts\",\n message: \"Collecting artifacts: screenshots, videos, traces.\",\n },\n REPORTING_STATUS_SUCCESS: {\n key: \"ReportingStatusSuccess\",\n message: \"Reporting upload status: SUCCESS\",\n },\n REPORTING_STATUS_PARTIAL: {\n key: \"ReportingStatusPartial\",\n message: \"Reporting upload status: Partially Uploaded\",\n },\n REPORTING_STATUS_FAILED: {\n key: \"ReportingStatusFailed\",\n message: \"Reporting upload status: FAILED\",\n },\n TEST_REPORT_VIEW_URL: {\n key: \"TestReportViewUrl\",\n message: \"Published report URL: \",\n formatWithUrl: (url: string): string => `Published report URL: ${url}`,\n },\n UPLOADING_ARTIFACTS: {\n key: \"UploadingArtifacts\",\n message: \"Uploading artifacts to storage\",\n formatWithDetails: (storageAccount: string, container: string, folder: string): string =>\n `Uploading artifacts to: storage account= ${storageAccount}, storage container= ${container}, folder= ${folder}`,\n },\n FAILED_TO_GET_WORKSPACE_METADATA: {\n key: \"FailedToGetWorkspaceMetadata\",\n message: \"Failed to get workspace metadata\",\n formatWithError: (error: string): string => error,\n },\n TEST_RUN_CREATION_FAILED: {\n key: \"TestRunCreationFailed\",\n message: \"Failed to create test run. Test execution will continue.\",\n formatWithErrorDetails: (errorDetails: string): string =>\n `Failed to create test run. Error: ${errorDetails}. Test execution will continue.`,\n },\n REPORTING_TEST_RUN_FAILED: {\n key: \"ReportingTestRunFailed\",\n message: \"Test run creation failed during setup.\",\n },\n REPORTER_REQUIRES_SERVICE_CONFIG: {\n key: \"ReporterRequiresServiceConfig\",\n message:\n \"Playwright Workspaces Reporter requires the use of service configuration via createAzurePlaywrightConfig. For more information, see https://aka.ms/pww-reporting.\",\n },\n};\n"]}
|
|
@@ -199,7 +199,7 @@ const getConnectOptions = async (options) => {
|
|
|
199
199
|
throw new Error(messages_js_1.ServiceErrorMessageConstants.INVALID_AUTH_TYPE_ERROR.message);
|
|
200
200
|
}
|
|
201
201
|
if (!token) {
|
|
202
|
-
throw new Error(messages_js_1.ServiceErrorMessageConstants.
|
|
202
|
+
throw new Error(messages_js_1.ServiceErrorMessageConstants.NO_AUTH_ERROR_PAT_TOKEN.message);
|
|
203
203
|
}
|
|
204
204
|
return {
|
|
205
205
|
wsEndpoint: (0, utils_js_1.getServiceWSEndpoint)(playwrightServiceConfig.runId, playwrightServiceConfig.serviceOs, playwrightServiceConfig.apiVersion),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightService.js","sourceRoot":"","sources":["../../../src/core/playwrightService.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,yDAIgC;AAChC,4FAAyD;AACzD,qFAA+E;AAC/E,oGAAiE;AAEjE,gDAa2B;AAC3B,uDAAqE;AAErE,2EAA0D;AAE1D,MAAM,uBAAuB,GAAG,CAAC,OAA4C,EAAQ,EAAE;IACrF,MAAM,oBAAoB,GACxB,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,uBAAuB,CAAC,KAAK,MAAM,CAAC;IAC/E,IAAI,oBAAoB;QAAE,OAAO;IACjC,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,uBAAuB,CAAC,GAAG,MAAM,CAAC;IAC3E,IAAI,OAAO,EAAE,eAAe,KAAK,0BAAW,CAAC,YAAY,EAAE,CAAC;QAC1D,IAAA,yCAA8B,GAAE,CAAC;IACnC,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,2BAA2B,GAAG,CAClC,UAAgC,EAChC,OAA4C,EACtB,EAAE;IACxB,IAAA,oCAAyB,GAAE,CAAC;IAC5B,IAAA,6BAAkB,GAAE,CAAC;IAErB,oEA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sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n DefaultConnectOptionsConstants,\n InternalEnvironmentVariables,\n ServiceAuth,\n} from \"../common/constants.js\";\nimport customerConfig from \"../common/customerConfig.js\";\nimport { PlaywrightServiceConfig } from \"../common/playwrightServiceConfig.js\";\nimport playwrightServiceEntra from \"./playwrightServiceEntra.js\";\nimport type { PlaywrightServiceAdditionalOptions, BrowserConnectOptions } from \"../common/types.js\";\nimport {\n fetchOrValidateAccessToken,\n getAccessToken,\n getServiceWSEndpoint,\n validateMptPAT,\n validatePlaywrightVersion,\n validateServiceUrl,\n exitWithFailureMessage,\n getPlaywrightVersion,\n getVersionInfo,\n throwErrorWithFailureMessage,\n getPackageVersion,\n warnIfAccessTokenCloseToExpiry,\n} from \"../utils/utils.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport type { PlaywrightTestConfig } from \"@playwright/test\";\nimport { globalPaths } from \"./playwrightServiceUtils.js\";\n\nconst performOneTimeOperation = (options?: PlaywrightServiceAdditionalOptions): void => {\n const oneTimeOperationFlag =\n process.env[InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] === \"true\";\n if (oneTimeOperationFlag) return;\n process.env[InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] = \"true\";\n if (options?.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n warnIfAccessTokenCloseToExpiry();\n }\n};\n\n/**\n * @public\n *\n * Generate playwright configuration integrated with Azure Playwright.\n *\n * @param baseConfig - base playwright configuration\n * @param options - additional options for the service\n * @returns PlaywrightConfig\n *\n * @example\n * ```\n * import { defineConfig } from \"playwright/test\";\n * import { createAzurePlaywrightConfig } from \"@azure/playwright\";\n * import playwrightConfig from \"./playwright.config\";\n *\n * export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig));\n * ```\n *\n * @example\n * ```\n * import { defineConfig } from \"playwright/test\";\n * import { createAzurePlaywrightConfig, ServiceOS, ServiceAuth } from \"@azure/playwright\";\n * import playwrightConfig from \"./playwright.config\";\n * import { DefaultAzureCredential } from '@azure/identity';\n *\n * export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig, {\n * credential: new DefaultAzureCredential(),\n * serviceAuthType: ServiceAuth.ENTRA_ID,\n * os: ServiceOS.WINDOWS\n * }));\n * ```\n */\nconst createAzurePlaywrightConfig = (\n baseConfig: PlaywrightTestConfig,\n options?: PlaywrightServiceAdditionalOptions,\n): PlaywrightTestConfig => {\n validatePlaywrightVersion();\n validateServiceUrl();\n\n // Set environment variable to indicate user is using service config\n process.env[InternalEnvironmentVariables.USING_SERVICE_CONFIG] = \"true\";\n const playwrightVersionInfo = getVersionInfo(getPlaywrightVersion());\n const isMultipleGlobalFileSupported =\n playwrightVersionInfo.major >= 1 && playwrightVersionInfo.minor >= 49;\n if (options?.credential) {\n playwrightServiceEntra.entraIdAccessToken = options.credential;\n }\n\n // if global setup/teardown is string -\n // 1. if multiple global file is supported, convert it to array\n // 2. wrap playwright-service global setup/teardown with customer provided global setup/teardown\n\n // if global setup/teardown is array -\n // 1. if multiple global file is not supported, throw error\n // 2. append playwright-service global setup/teardown with customer provided global setup/teardown\n if (baseConfig && baseConfig.globalSetup) {\n if (typeof baseConfig.globalSetup === \"string\") {\n if (isMultipleGlobalFileSupported) {\n customerConfig.globalSetup = [baseConfig.globalSetup];\n } else {\n customerConfig.globalSetup = baseConfig.globalSetup;\n }\n } else {\n if (!isMultipleGlobalFileSupported) {\n throw new Error(\n ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message,\n );\n }\n customerConfig.globalSetup = baseConfig.globalSetup;\n }\n }\n\n if (baseConfig && baseConfig.globalTeardown) {\n if (typeof baseConfig.globalTeardown === \"string\") {\n if (isMultipleGlobalFileSupported) {\n customerConfig.globalTeardown = [baseConfig.globalTeardown];\n } else {\n customerConfig.globalTeardown = baseConfig.globalTeardown;\n }\n } else {\n if (!isMultipleGlobalFileSupported) {\n throw new Error(\n ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message,\n );\n }\n customerConfig.globalTeardown = baseConfig.globalTeardown;\n }\n }\n\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n playwrightServiceConfig.setOptions(options);\n playwrightServiceConfig.serviceAuthType =\n options?.serviceAuthType || DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;\n\n const globalFunctions: any = {};\n\n if (options?.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n // mpt PAT requested and set by the customer, no need to setup entra lifecycle handlers\n validateMptPAT(exitWithFailureMessage);\n }\n // If multiple global file is supported, append playwright-service global setup/teardown with customer provided global setup/teardown\n if (isMultipleGlobalFileSupported) {\n globalFunctions.globalSetup = [] as string[];\n globalFunctions.globalTeardown = [] as string[];\n if (customerConfig.globalSetup) {\n globalFunctions.globalSetup.push(...(customerConfig.globalSetup as string[]));\n }\n if (customerConfig.globalTeardown) {\n globalFunctions.globalTeardown.push(...(customerConfig.globalTeardown as string[]));\n }\n globalFunctions.globalSetup.push(globalPaths.setup);\n globalFunctions.globalTeardown.push(globalPaths.teardown);\n } else {\n // If multiple global file is not supported, wrap playwright-service global setup/teardown with customer provided global setup/teardown\n globalFunctions.globalSetup = globalPaths.setup;\n globalFunctions.globalTeardown = globalPaths.teardown;\n }\n\n performOneTimeOperation(options);\n\n if (!process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED]) {\n process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] = \"true\";\n console.log(\"\\nRunning tests using Playwright workspaces.\");\n }\n\n return {\n use: {\n connectOptions: {\n wsEndpoint: getServiceWSEndpoint(\n playwrightServiceConfig.runId,\n playwrightServiceConfig.serviceOs,\n playwrightServiceConfig.apiVersion,\n ),\n headers: {\n Authorization: `Bearer ${getAccessToken()}`,\n \"x-ms-package-version\": `@azure/playwright/${getPackageVersion()}`,\n },\n timeout: playwrightServiceConfig.connectTimeout,\n exposeNetwork: playwrightServiceConfig.exposeNetwork,\n slowMo: playwrightServiceConfig.slowMo,\n },\n },\n ...globalFunctions,\n };\n};\n\n/**\n * @public\n *\n * Get connect options required to connect to Azure Playwright's cloud hosted browsers.\n *\n * @param options - additional options for the service\n * @returns BrowserConnectOptions\n *\n * @example\n * ```\n * import playwright, { test, expect, BrowserType } from \"@playwright/test\";\n * import { getConnectOptions } from \"@azure/playwright\";\n *\n * test('has title', async ({ browserName }) => {\n * const { wsEndpoint, options } = await getConnectOptions();\n * const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);\n * const context = await browser.newContext();\n * const page = await context.newPage();\n *\n * await page.goto('https://playwright.dev/');\n * await expect(page).toHaveTitle(/Playwright/);\n *\n * await page.close();\n * await context.close();\n * await browser.close();\n * });\n * ```\n */\nconst getConnectOptions = async (\n options?: PlaywrightServiceAdditionalOptions,\n): Promise<BrowserConnectOptions> => {\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n\n playwrightServiceConfig.setOptions(options, true);\n performOneTimeOperation(options);\n playwrightServiceConfig.serviceAuthType =\n options?.serviceAuthType || DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;\n\n let token: string | undefined;\n if (playwrightServiceConfig.serviceAuthType === ServiceAuth.ENTRA_ID) {\n if (!options?.credential) {\n throw new Error(ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);\n }\n playwrightServiceEntra.entraIdAccessToken = options.credential;\n token = await fetchOrValidateAccessToken(options.credential);\n } else if (playwrightServiceConfig.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n validateMptPAT(throwErrorWithFailureMessage);\n token = getAccessToken();\n } else {\n throw new Error(ServiceErrorMessageConstants.INVALID_AUTH_TYPE_ERROR.message);\n }\n\n if (!token) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);\n }\n\n return {\n wsEndpoint: getServiceWSEndpoint(\n playwrightServiceConfig.runId,\n playwrightServiceConfig.serviceOs,\n playwrightServiceConfig.apiVersion,\n ),\n options: {\n headers: {\n Authorization: `Bearer ${token}`,\n \"x-ms-package-version\": `@azure/playwright/${getPackageVersion()}`,\n },\n timeout: playwrightServiceConfig.connectTimeout,\n exposeNetwork: playwrightServiceConfig.exposeNetwork,\n slowMo: playwrightServiceConfig.slowMo,\n },\n };\n};\n\nexport { createAzurePlaywrightConfig, getConnectOptions };\n"]}
|
|
1
|
+
{"version":3,"file":"playwrightService.js","sourceRoot":"","sources":["../../../src/core/playwrightService.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,yDAIgC;AAChC,4FAAyD;AACzD,qFAA+E;AAC/E,oGAAiE;AAEjE,gDAa2B;AAC3B,uDAAqE;AAErE,2EAA0D;AAE1D,MAAM,uBAAuB,GAAG,CAAC,OAA4C,EAAQ,EAAE;IACrF,MAAM,oBAAoB,GACxB,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,uBAAuB,CAAC,KAAK,MAAM,CAAC;IAC/E,IAAI,oBAAoB;QAAE,OAAO;IACjC,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,uBAAuB,CAAC,GAAG,MAAM,CAAC;IAC3E,IAAI,OAAO,EAAE,eAAe,KAAK,0BAAW,CAAC,YAAY,EAAE,CAAC;QAC1D,IAAA,yCAA8B,GAAE,CAAC;IACnC,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,2BAA2B,GAAG,CAClC,UAAgC,EAChC,OAA4C,EACtB,EAAE;IACxB,IAAA,oCAAyB,GAAE,CAAC;IAC5B,IAAA,6BAAkB,GAAE,CAAC;IAErB,oEAAoE;IACpE,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC;IACxE,MAAM,qBAAqB,GAAG,IAAA,yBAAc,EAAC,IA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E,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,0CAA4B,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;QACjF,CAAC;QACD,mCAAsB,CAAC,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;QAC/D,KAAK,GAAG,MAAM,IAAA,qCAA0B,EAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/D,CAAC;SAAM,IAAI,uBAAuB,CAAC,eAAe,KAAK,0BAAW,CAAC,YAAY,EAAE,CAAC;QAChF,IAAA,yBAAc,EAAC,uCAA4B,CAAC,CAAC;QAC7C,KAAK,GAAG,IAAA,yBAAc,GAAE,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,0CAA4B,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,0CAA4B,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChF,CAAC;IAED,OAAO;QACL,UAAU,EAAE,IAAA,+BAAoB,EAC9B,uBAAuB,CAAC,KAAK,EAC7B,uBAAuB,CAAC,SAAS,EACjC,uBAAuB,CAAC,UAAU,CACnC;QACD,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,sBAAsB,EAAE,qBAAqB,IAAA,4BAAiB,GAAE,EAAE;aACnE;YACD,OAAO,EAAE,uBAAuB,CAAC,cAAc;YAC/C,aAAa,EAAE,uBAAuB,CAAC,aAAa;YACpD,MAAM,EAAE,uBAAuB,CAAC,MAAM;SACvC;KACF,CAAC;AACJ,CAAC,CAAC;AAEoC,8CAAiB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n DefaultConnectOptionsConstants,\n InternalEnvironmentVariables,\n ServiceAuth,\n} from \"../common/constants.js\";\nimport customerConfig from \"../common/customerConfig.js\";\nimport { PlaywrightServiceConfig } from \"../common/playwrightServiceConfig.js\";\nimport playwrightServiceEntra from \"./playwrightServiceEntra.js\";\nimport type { PlaywrightServiceAdditionalOptions, BrowserConnectOptions } from \"../common/types.js\";\nimport {\n fetchOrValidateAccessToken,\n getAccessToken,\n getServiceWSEndpoint,\n validateMptPAT,\n validatePlaywrightVersion,\n validateServiceUrl,\n exitWithFailureMessage,\n getPlaywrightVersion,\n getVersionInfo,\n throwErrorWithFailureMessage,\n getPackageVersion,\n warnIfAccessTokenCloseToExpiry,\n} from \"../utils/utils.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport type { PlaywrightTestConfig } from \"@playwright/test\";\nimport { globalPaths } from \"./playwrightServiceUtils.js\";\n\nconst performOneTimeOperation = (options?: PlaywrightServiceAdditionalOptions): void => {\n const oneTimeOperationFlag =\n process.env[InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] === \"true\";\n if (oneTimeOperationFlag) return;\n process.env[InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] = \"true\";\n if (options?.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n warnIfAccessTokenCloseToExpiry();\n }\n};\n\n/**\n * @public\n *\n * Generate playwright configuration integrated with Azure Playwright.\n *\n * @param baseConfig - base playwright configuration\n * @param options - additional options for the service\n * @returns PlaywrightConfig\n *\n * @example\n * ```\n * import { defineConfig } from \"playwright/test\";\n * import { createAzurePlaywrightConfig } from \"@azure/playwright\";\n * import playwrightConfig from \"./playwright.config\";\n *\n * export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig));\n * ```\n *\n * @example\n * ```\n * import { defineConfig } from \"playwright/test\";\n * import { createAzurePlaywrightConfig, ServiceOS, ServiceAuth } from \"@azure/playwright\";\n * import playwrightConfig from \"./playwright.config\";\n * import { DefaultAzureCredential } from '@azure/identity';\n *\n * export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig, {\n * credential: new DefaultAzureCredential(),\n * serviceAuthType: ServiceAuth.ENTRA_ID,\n * os: ServiceOS.WINDOWS\n * }));\n * ```\n */\nconst createAzurePlaywrightConfig = (\n baseConfig: PlaywrightTestConfig,\n options?: PlaywrightServiceAdditionalOptions,\n): PlaywrightTestConfig => {\n validatePlaywrightVersion();\n validateServiceUrl();\n\n // Set environment variable to indicate user is using service config\n process.env[InternalEnvironmentVariables.USING_SERVICE_CONFIG] = \"true\";\n const playwrightVersionInfo = getVersionInfo(getPlaywrightVersion());\n const isMultipleGlobalFileSupported =\n playwrightVersionInfo.major >= 1 && playwrightVersionInfo.minor >= 49;\n if (options?.credential) {\n playwrightServiceEntra.entraIdAccessToken = options.credential;\n }\n\n // if global setup/teardown is string -\n // 1. if multiple global file is supported, convert it to array\n // 2. wrap playwright-service global setup/teardown with customer provided global setup/teardown\n\n // if global setup/teardown is array -\n // 1. if multiple global file is not supported, throw error\n // 2. append playwright-service global setup/teardown with customer provided global setup/teardown\n if (baseConfig && baseConfig.globalSetup) {\n if (typeof baseConfig.globalSetup === \"string\") {\n if (isMultipleGlobalFileSupported) {\n customerConfig.globalSetup = [baseConfig.globalSetup];\n } else {\n customerConfig.globalSetup = baseConfig.globalSetup;\n }\n } else {\n if (!isMultipleGlobalFileSupported) {\n throw new Error(\n ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message,\n );\n }\n customerConfig.globalSetup = baseConfig.globalSetup;\n }\n }\n\n if (baseConfig && baseConfig.globalTeardown) {\n if (typeof baseConfig.globalTeardown === \"string\") {\n if (isMultipleGlobalFileSupported) {\n customerConfig.globalTeardown = [baseConfig.globalTeardown];\n } else {\n customerConfig.globalTeardown = baseConfig.globalTeardown;\n }\n } else {\n if (!isMultipleGlobalFileSupported) {\n throw new Error(\n ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message,\n );\n }\n customerConfig.globalTeardown = baseConfig.globalTeardown;\n }\n }\n\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n playwrightServiceConfig.setOptions(options);\n playwrightServiceConfig.serviceAuthType =\n options?.serviceAuthType || DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;\n\n const globalFunctions: any = {};\n\n if (options?.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n // mpt PAT requested and set by the customer, no need to setup entra lifecycle handlers\n validateMptPAT(exitWithFailureMessage);\n }\n // If multiple global file is supported, append playwright-service global setup/teardown with customer provided global setup/teardown\n if (isMultipleGlobalFileSupported) {\n globalFunctions.globalSetup = [] as string[];\n globalFunctions.globalTeardown = [] as string[];\n if (customerConfig.globalSetup) {\n globalFunctions.globalSetup.push(...(customerConfig.globalSetup as string[]));\n }\n if (customerConfig.globalTeardown) {\n globalFunctions.globalTeardown.push(...(customerConfig.globalTeardown as string[]));\n }\n globalFunctions.globalSetup.push(globalPaths.setup);\n globalFunctions.globalTeardown.push(globalPaths.teardown);\n } else {\n // If multiple global file is not supported, wrap playwright-service global setup/teardown with customer provided global setup/teardown\n globalFunctions.globalSetup = globalPaths.setup;\n globalFunctions.globalTeardown = globalPaths.teardown;\n }\n\n performOneTimeOperation(options);\n\n if (!process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED]) {\n process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] = \"true\";\n console.log(\"\\nRunning tests using Playwright workspaces.\");\n }\n\n return {\n use: {\n connectOptions: {\n wsEndpoint: getServiceWSEndpoint(\n playwrightServiceConfig.runId,\n playwrightServiceConfig.serviceOs,\n playwrightServiceConfig.apiVersion,\n ),\n headers: {\n Authorization: `Bearer ${getAccessToken()}`,\n \"x-ms-package-version\": `@azure/playwright/${getPackageVersion()}`,\n },\n timeout: playwrightServiceConfig.connectTimeout,\n exposeNetwork: playwrightServiceConfig.exposeNetwork,\n slowMo: playwrightServiceConfig.slowMo,\n },\n },\n ...globalFunctions,\n };\n};\n\n/**\n * @public\n *\n * Get connect options required to connect to Azure Playwright's cloud hosted browsers.\n *\n * @param options - additional options for the service\n * @returns BrowserConnectOptions\n *\n * @example\n * ```\n * import playwright, { test, expect, BrowserType } from \"@playwright/test\";\n * import { getConnectOptions } from \"@azure/playwright\";\n *\n * test('has title', async ({ browserName }) => {\n * const { wsEndpoint, options } = await getConnectOptions();\n * const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);\n * const context = await browser.newContext();\n * const page = await context.newPage();\n *\n * await page.goto('https://playwright.dev/');\n * await expect(page).toHaveTitle(/Playwright/);\n *\n * await page.close();\n * await context.close();\n * await browser.close();\n * });\n * ```\n */\nconst getConnectOptions = async (\n options?: PlaywrightServiceAdditionalOptions,\n): Promise<BrowserConnectOptions> => {\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n\n playwrightServiceConfig.setOptions(options, true);\n performOneTimeOperation(options);\n playwrightServiceConfig.serviceAuthType =\n options?.serviceAuthType || DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;\n\n let token: string | undefined;\n if (playwrightServiceConfig.serviceAuthType === ServiceAuth.ENTRA_ID) {\n if (!options?.credential) {\n throw new Error(ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);\n }\n playwrightServiceEntra.entraIdAccessToken = options.credential;\n token = await fetchOrValidateAccessToken(options.credential);\n } else if (playwrightServiceConfig.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n validateMptPAT(throwErrorWithFailureMessage);\n token = getAccessToken();\n } else {\n throw new Error(ServiceErrorMessageConstants.INVALID_AUTH_TYPE_ERROR.message);\n }\n\n if (!token) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR_PAT_TOKEN.message);\n }\n\n return {\n wsEndpoint: getServiceWSEndpoint(\n playwrightServiceConfig.runId,\n playwrightServiceConfig.serviceOs,\n playwrightServiceConfig.apiVersion,\n ),\n options: {\n headers: {\n Authorization: `Bearer ${token}`,\n \"x-ms-package-version\": `@azure/playwright/${getPackageVersion()}`,\n },\n timeout: playwrightServiceConfig.connectTimeout,\n exposeNetwork: playwrightServiceConfig.exposeNetwork,\n slowMo: playwrightServiceConfig.slowMo,\n },\n };\n};\n\nexport { createAzurePlaywrightConfig, getConnectOptions };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightReporter.d.ts","sourceRoot":"","sources":["../../../src/reporter/playwrightReporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"playwrightReporter.d.ts","sourceRoot":"","sources":["../../../src/reporter/playwrightReporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAetE;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,QAAQ;IACzD,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,kBAAkB,CAAS;IAEnC;;;;OAIG;IAEG,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAsFhD;;OAEG;IAEG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAiCd,gBAAgB;IAsB9B,OAAO,CAAC,iCAAiC;CAuC1C"}
|
|
@@ -7,6 +7,7 @@ const playwrightServiceConfig_js_1 = require("../common/playwrightServiceConfig.
|
|
|
7
7
|
const constants_js_1 = require("../common/constants.js");
|
|
8
8
|
const messages_js_1 = require("../common/messages.js");
|
|
9
9
|
const PlaywrightServiceClient_js_1 = require("../utils/PlaywrightServiceClient.js");
|
|
10
|
+
const getPlaywrightVersion_js_1 = require("../utils/getPlaywrightVersion.js");
|
|
10
11
|
/**
|
|
11
12
|
* Azure Playwright Reporter - Uploads generated Playwright test report folder to Azure Storage.
|
|
12
13
|
*/
|
|
@@ -22,6 +23,25 @@ class PlaywrightReporter {
|
|
|
22
23
|
async onBegin(config) {
|
|
23
24
|
logger_js_1.coreLogger.info(`Reporter configuration: ${JSON.stringify(config.reporter, null, 2)}`);
|
|
24
25
|
this.config = config;
|
|
26
|
+
// Check Playwright version for reporting feature compatibility
|
|
27
|
+
try {
|
|
28
|
+
const playwrightVersion = (0, getPlaywrightVersion_js_1.getPlaywrightVersion)();
|
|
29
|
+
const playwrightVersionInfo = (0, utils_js_1.getVersionInfo)(playwrightVersion);
|
|
30
|
+
// Check if version is < 1.57
|
|
31
|
+
const isReportingSupportedVersion = playwrightVersionInfo.major > 1 ||
|
|
32
|
+
(playwrightVersionInfo.major === 1 && playwrightVersionInfo.minor >= 57);
|
|
33
|
+
if (!isReportingSupportedVersion) {
|
|
34
|
+
console.error(messages_js_1.ServiceErrorMessageConstants.PLAYWRIGHT_VERSION_TOO_OLD_FOR_REPORTING.message);
|
|
35
|
+
this.isReportingEnabled = false;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
logger_js_1.coreLogger.error(`Failed to get Playwright version: ${error}`);
|
|
41
|
+
console.error(messages_js_1.ServiceErrorMessageConstants.PLAYWRIGHT_VERSION_TOO_OLD_FOR_REPORTING.message);
|
|
42
|
+
this.isReportingEnabled = false;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
25
45
|
// Check if using service config
|
|
26
46
|
const usingServiceConfig = process.env[constants_js_1.InternalEnvironmentVariables.USING_SERVICE_CONFIG] === "true";
|
|
27
47
|
logger_js_1.coreLogger.info(`Using service config: ${usingServiceConfig}`);
|