From 5d40fff13b750775a22122ce55f89d00b113017f Mon Sep 17 00:00:00 2001 From: Fernando Alvarez Date: Sun, 13 Mar 2022 14:07:53 -0400 Subject: [PATCH] Title test in app insights --- src/AppInsightsAvailabilityFixture.ts | 2 +- src/PlaywrightAvailabilityTester.ts | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/AppInsightsAvailabilityFixture.ts b/src/AppInsightsAvailabilityFixture.ts index 4338e30..dfe2bac 100644 --- a/src/AppInsightsAvailabilityFixture.ts +++ b/src/AppInsightsAvailabilityFixture.ts @@ -8,7 +8,7 @@ const test = baseTest.extend({ page: async ({ page }, use, testInfo) => { console.log(appInsightsAvailabilityTesterTag, testInfo.title); - var pwat = new PlaywrightAvailabilityTester(); + var pwat = new PlaywrightAvailabilityTester(testInfo.title); let browserContext = page.context(); if (browserContext) { diff --git a/src/PlaywrightAvailabilityTester.ts b/src/PlaywrightAvailabilityTester.ts index 817ef1d..b3e632a 100644 --- a/src/PlaywrightAvailabilityTester.ts +++ b/src/PlaywrightAvailabilityTester.ts @@ -36,8 +36,9 @@ export class PlaywrightAvailabilityTester { private options?: PlaywrightAvailabilityTesterOptions; - constructor(options?: PlaywrightAvailabilityTesterOptions) { + constructor(testName: any, options?: PlaywrightAvailabilityTesterOptions) { this.options = options; + this.testName = testName.toString(); if (options?.logDebugToTelemetryClient) { options.log = (...args: any[]) => @@ -181,11 +182,8 @@ export class PlaywrightAvailabilityTester { // Azure Functions uses 'APPSETTING_WEBSITE_SITE_NAME' environment variable to pass the logic app name // APPSETTING_TESTNAME can be used to override that - let testName = this.testName; - if (!testName || testName == "") { - testName = process.env.APPSETTING_TESTNAME || process.env.APPSETTING_WEBSITE_SITE_NAME || "NO_TESTNAME"; - } - bci.testName = testName; + + bci.testName = this.testName; (browserContext)[BrowserContextInsights.browserContextInsightsAttachedPropertyName] = bci; }