@azure/playwright 1.1.2 → 1.1.3-alpha.20260310.1

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.
Files changed (168) hide show
  1. package/dist/browser/common/types.d.ts +1 -1
  2. package/dist/browser/common/types.d.ts.map +1 -1
  3. package/dist/browser/common/types.js.map +1 -1
  4. package/dist/browser/index.d.ts +1 -1
  5. package/dist/browser/index.d.ts.map +1 -1
  6. package/dist/browser/index.js.map +1 -1
  7. package/dist/browser/utils/PlaywrightServiceClient.d.ts +1 -1
  8. package/dist/browser/utils/PlaywrightServiceClient.d.ts.map +1 -1
  9. package/dist/browser/utils/PlaywrightServiceClient.js.map +1 -1
  10. package/dist/browser/utils/playwrightReporterStorageManager.d.ts.map +1 -1
  11. package/dist/browser/utils/playwrightReporterStorageManager.js.map +1 -1
  12. package/dist/browser/utils/utils.d.ts +2 -2
  13. package/dist/browser/utils/utils.d.ts.map +1 -1
  14. package/dist/browser/utils/utils.js.map +1 -1
  15. package/dist/commonjs/common/constants.js +127 -95
  16. package/dist/commonjs/common/constants.js.map +7 -1
  17. package/dist/commonjs/common/customerConfig.js +31 -14
  18. package/dist/commonjs/common/customerConfig.js.map +7 -1
  19. package/dist/commonjs/common/entraIdAccessToken.js +106 -83
  20. package/dist/commonjs/common/entraIdAccessToken.js.map +7 -1
  21. package/dist/commonjs/common/environmentVariables.js +43 -24
  22. package/dist/commonjs/common/environmentVariables.js.map +7 -1
  23. package/dist/commonjs/common/executor.js +88 -67
  24. package/dist/commonjs/common/executor.js.map +7 -1
  25. package/dist/commonjs/common/httpService.js +54 -35
  26. package/dist/commonjs/common/httpService.js.map +7 -1
  27. package/dist/commonjs/common/logger.js +28 -8
  28. package/dist/commonjs/common/logger.js.map +7 -1
  29. package/dist/commonjs/common/messages.js +189 -169
  30. package/dist/commonjs/common/messages.js.map +7 -1
  31. package/dist/commonjs/common/playwrightServiceConfig.js +113 -98
  32. package/dist/commonjs/common/playwrightServiceConfig.js.map +7 -1
  33. package/dist/commonjs/common/state.js +30 -10
  34. package/dist/commonjs/common/state.js.map +7 -1
  35. package/dist/commonjs/common/types.d.ts +1 -1
  36. package/dist/commonjs/common/types.d.ts.map +1 -1
  37. package/dist/commonjs/common/types.js +15 -5
  38. package/dist/commonjs/common/types.js.map +7 -1
  39. package/dist/commonjs/core/global/playwright-service-global-setup.js +52 -26
  40. package/dist/commonjs/core/global/playwright-service-global-setup.js.map +7 -1
  41. package/dist/commonjs/core/global/playwright-service-global-teardown.js +49 -20
  42. package/dist/commonjs/core/global/playwright-service-global-teardown.js.map +7 -1
  43. package/dist/commonjs/core/initializePlaywrightServiceTestRun.js +39 -27
  44. package/dist/commonjs/core/initializePlaywrightServiceTestRun.js.map +7 -1
  45. package/dist/commonjs/core/playwrightService.js +166 -205
  46. package/dist/commonjs/core/playwrightService.js.map +7 -1
  47. package/dist/commonjs/core/playwrightServiceEntra.js +67 -48
  48. package/dist/commonjs/core/playwrightServiceEntra.js.map +7 -1
  49. package/dist/commonjs/core/playwrightServiceUtils.d.ts +1 -1
  50. package/dist/commonjs/core/playwrightServiceUtils.d.ts.map +1 -0
  51. package/dist/commonjs/core/playwrightServiceUtils.js +44 -11
  52. package/dist/commonjs/core/playwrightServiceUtils.js.map +7 -0
  53. package/dist/commonjs/index.d.ts +1 -1
  54. package/dist/commonjs/index.d.ts.map +1 -1
  55. package/dist/commonjs/index.js +36 -18
  56. package/dist/commonjs/index.js.map +7 -1
  57. package/dist/commonjs/reporter/index.js +34 -15
  58. package/dist/commonjs/reporter/index.js.map +7 -1
  59. package/dist/commonjs/reporter/playwrightReporter.js +222 -216
  60. package/dist/commonjs/reporter/playwrightReporter.js.map +7 -1
  61. package/dist/commonjs/tsdoc-metadata.json +1 -1
  62. package/dist/commonjs/utils/PlaywrightServiceClient.d.ts +1 -1
  63. package/dist/commonjs/utils/PlaywrightServiceClient.d.ts.map +1 -1
  64. package/dist/commonjs/utils/PlaywrightServiceClient.js +140 -91
  65. package/dist/commonjs/utils/PlaywrightServiceClient.js.map +7 -1
  66. package/dist/commonjs/utils/cIInfoProvider.js +81 -74
  67. package/dist/commonjs/utils/cIInfoProvider.js.map +7 -1
  68. package/dist/commonjs/utils/getPackageVersion.d.ts +1 -1
  69. package/dist/commonjs/utils/getPackageVersion.d.ts.map +1 -0
  70. package/dist/commonjs/utils/getPackageVersion.js +50 -19
  71. package/dist/commonjs/utils/getPackageVersion.js.map +7 -0
  72. package/dist/commonjs/utils/getPlaywrightVersion.js +42 -21
  73. package/dist/commonjs/utils/getPlaywrightVersion.js.map +7 -1
  74. package/dist/commonjs/utils/packageManager.js +59 -40
  75. package/dist/commonjs/utils/packageManager.js.map +7 -1
  76. package/dist/commonjs/utils/parseJwt.js +37 -17
  77. package/dist/commonjs/utils/parseJwt.js.map +7 -1
  78. package/dist/commonjs/utils/playwrightReporterStorageManager.d.ts.map +1 -1
  79. package/dist/commonjs/utils/playwrightReporterStorageManager.js +381 -342
  80. package/dist/commonjs/utils/playwrightReporterStorageManager.js.map +7 -1
  81. package/dist/commonjs/utils/utils.d.ts +2 -2
  82. package/dist/commonjs/utils/utils.d.ts.map +1 -1
  83. package/dist/commonjs/utils/utils.js +417 -369
  84. package/dist/commonjs/utils/utils.js.map +7 -1
  85. package/dist/esm/common/constants.js +92 -92
  86. package/dist/esm/common/constants.js.map +7 -1
  87. package/dist/esm/common/customerConfig.js +11 -11
  88. package/dist/esm/common/customerConfig.js.map +7 -1
  89. package/dist/esm/common/entraIdAccessToken.js +85 -77
  90. package/dist/esm/common/entraIdAccessToken.js.map +7 -1
  91. package/dist/esm/common/environmentVariables.js +19 -19
  92. package/dist/esm/common/environmentVariables.js.map +7 -1
  93. package/dist/esm/common/executor.js +51 -58
  94. package/dist/esm/common/executor.js.map +7 -1
  95. package/dist/esm/common/httpService.js +34 -29
  96. package/dist/esm/common/httpService.js.map +7 -1
  97. package/dist/esm/common/logger.js +4 -4
  98. package/dist/esm/common/logger.js.map +7 -1
  99. package/dist/esm/common/messages.js +166 -166
  100. package/dist/esm/common/messages.js.map +7 -1
  101. package/dist/esm/common/playwrightServiceConfig.js +91 -91
  102. package/dist/esm/common/playwrightServiceConfig.js.map +7 -1
  103. package/dist/esm/common/state.js +7 -7
  104. package/dist/esm/common/state.js.map +7 -1
  105. package/dist/esm/common/types.d.ts +1 -1
  106. package/dist/esm/common/types.d.ts.map +1 -1
  107. package/dist/esm/common/types.js +0 -4
  108. package/dist/esm/common/types.js.map +7 -1
  109. package/dist/esm/core/global/playwright-service-global-setup.js +17 -17
  110. package/dist/esm/core/global/playwright-service-global-setup.js.map +7 -1
  111. package/dist/esm/core/global/playwright-service-global-teardown.js +16 -13
  112. package/dist/esm/core/global/playwright-service-global-teardown.js.map +7 -1
  113. package/dist/esm/core/initializePlaywrightServiceTestRun.js +13 -21
  114. package/dist/esm/core/initializePlaywrightServiceTestRun.js.map +7 -1
  115. package/dist/esm/core/playwrightService.js +144 -195
  116. package/dist/esm/core/playwrightService.js.map +7 -1
  117. package/dist/esm/core/playwrightServiceEntra.js +44 -42
  118. package/dist/esm/core/playwrightServiceEntra.js.map +7 -1
  119. package/dist/esm/core/playwrightServiceUtils.js +6 -8
  120. package/dist/esm/core/playwrightServiceUtils.js.map +7 -1
  121. package/dist/esm/index.d.ts +1 -1
  122. package/dist/esm/index.d.ts.map +1 -1
  123. package/dist/esm/index.js +7 -9
  124. package/dist/esm/index.js.map +7 -1
  125. package/dist/esm/reporter/index.js +4 -11
  126. package/dist/esm/reporter/index.js.map +7 -1
  127. package/dist/esm/reporter/playwrightReporter.js +202 -207
  128. package/dist/esm/reporter/playwrightReporter.js.map +7 -1
  129. package/dist/esm/utils/PlaywrightServiceClient.d.ts +1 -1
  130. package/dist/esm/utils/PlaywrightServiceClient.d.ts.map +1 -1
  131. package/dist/esm/utils/PlaywrightServiceClient.js +120 -85
  132. package/dist/esm/utils/PlaywrightServiceClient.js.map +7 -1
  133. package/dist/esm/utils/cIInfoProvider.js +58 -71
  134. package/dist/esm/utils/cIInfoProvider.js.map +7 -1
  135. package/dist/esm/utils/getPackageVersion.js +12 -17
  136. package/dist/esm/utils/getPackageVersion.js.map +7 -1
  137. package/dist/esm/utils/getPlaywrightVersion.js +15 -13
  138. package/dist/esm/utils/getPlaywrightVersion.js.map +7 -1
  139. package/dist/esm/utils/packageManager.js +37 -37
  140. package/dist/esm/utils/packageManager.js.map +7 -1
  141. package/dist/esm/utils/parseJwt.js +15 -14
  142. package/dist/esm/utils/parseJwt.js.map +7 -1
  143. package/dist/esm/utils/playwrightReporterStorageManager.d.ts.map +1 -1
  144. package/dist/esm/utils/playwrightReporterStorageManager.js +358 -333
  145. package/dist/esm/utils/playwrightReporterStorageManager.js.map +7 -1
  146. package/dist/esm/utils/utils.d.ts +2 -2
  147. package/dist/esm/utils/utils.d.ts.map +1 -1
  148. package/dist/esm/utils/utils.js +377 -350
  149. package/dist/esm/utils/utils.js.map +7 -1
  150. package/dist/react-native/common/types.d.ts +1 -1
  151. package/dist/react-native/common/types.d.ts.map +1 -1
  152. package/dist/react-native/common/types.js.map +1 -1
  153. package/dist/react-native/index.d.ts +1 -1
  154. package/dist/react-native/index.d.ts.map +1 -1
  155. package/dist/react-native/index.js.map +1 -1
  156. package/dist/react-native/utils/PlaywrightServiceClient.d.ts +1 -1
  157. package/dist/react-native/utils/PlaywrightServiceClient.d.ts.map +1 -1
  158. package/dist/react-native/utils/PlaywrightServiceClient.js.map +1 -1
  159. package/dist/react-native/utils/playwrightReporterStorageManager.d.ts.map +1 -1
  160. package/dist/react-native/utils/playwrightReporterStorageManager.js.map +1 -1
  161. package/dist/react-native/utils/utils.d.ts +2 -2
  162. package/dist/react-native/utils/utils.d.ts.map +1 -1
  163. package/dist/react-native/utils/utils.js.map +1 -1
  164. package/package.json +6 -24
  165. package/dist/commonjs/core/playwrightServiceUtils-cjs.cjs.map +0 -1
  166. package/dist/commonjs/core/playwrightServiceUtils-cjs.d.cts.map +0 -1
  167. package/dist/commonjs/utils/getPackageVersion-cjs.cjs.map +0 -1
  168. package/dist/commonjs/utils/getPackageVersion-cjs.d.cts.map +0 -1
@@ -1,29 +1,41 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.initializePlaywrightServiceTestRun = initializePlaywrightServiceTestRun;
6
- const PlaywrightServiceClient_js_1 = require("../utils/PlaywrightServiceClient.js");
7
- const playwrightServiceConfig_js_1 = require("../common/playwrightServiceConfig.js");
8
- const utils_js_1 = require("../utils/utils.js");
9
- const cIInfoProvider_js_1 = require("../utils/cIInfoProvider.js");
10
- /**
11
- * Initializes the Playwright workspaces by setting up authentication and creating a test run.
12
- *
13
- * @param config - The full Playwright configuration
14
- * @returns Promise that resolves when service initialization is complete
15
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var initializePlaywrightServiceTestRun_exports = {};
19
+ __export(initializePlaywrightServiceTestRun_exports, {
20
+ initializePlaywrightServiceTestRun: () => initializePlaywrightServiceTestRun
21
+ });
22
+ module.exports = __toCommonJS(initializePlaywrightServiceTestRun_exports);
23
+ var import_PlaywrightServiceClient = require("../utils/PlaywrightServiceClient.js");
24
+ var import_playwrightServiceConfig = require("../common/playwrightServiceConfig.js");
25
+ var import_utils = require("../utils/utils.js");
26
+ var import_cIInfoProvider = require("../utils/cIInfoProvider.js");
16
27
  async function initializePlaywrightServiceTestRun(config) {
17
- const playwrightServiceApiClient = new PlaywrightServiceClient_js_1.PlaywrightServiceClient();
18
- const playwrightServiceConfig = playwrightServiceConfig_js_1.PlaywrightServiceConfig.instance;
19
- const ciConfigInfo = cIInfoProvider_js_1.CIInfoProvider.getCIInfo();
20
- const testRunCreatePayload = {
21
- displayName: playwrightServiceConfig.runName === ""
22
- ? playwrightServiceConfig.runId
23
- : playwrightServiceConfig.runName,
24
- config: (0, utils_js_1.getTestRunConfig)(config),
25
- ciConfig: ciConfigInfo,
26
- };
27
- await playwrightServiceApiClient.createOrUpdateTestRun(testRunCreatePayload);
28
+ const playwrightServiceApiClient = new import_PlaywrightServiceClient.PlaywrightServiceClient();
29
+ const playwrightServiceConfig = import_playwrightServiceConfig.PlaywrightServiceConfig.instance;
30
+ const ciConfigInfo = import_cIInfoProvider.CIInfoProvider.getCIInfo();
31
+ const testRunCreatePayload = {
32
+ displayName: playwrightServiceConfig.runName === "" ? playwrightServiceConfig.runId : playwrightServiceConfig.runName,
33
+ config: (0, import_utils.getTestRunConfig)(config),
34
+ ciConfig: ciConfigInfo
35
+ };
36
+ await playwrightServiceApiClient.createOrUpdateTestRun(testRunCreatePayload);
28
37
  }
29
- //# sourceMappingURL=initializePlaywrightServiceTestRun.js.map
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ initializePlaywrightServiceTestRun
41
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"initializePlaywrightServiceTestRun.js","sourceRoot":"","sources":["../../../src/core/initializePlaywrightServiceTestRun.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAclC,gFAeC;AA1BD,oFAA8E;AAC9E,qFAA+E;AAC/E,gDAAqD;AACrD,kEAA4D;AAE5D;;;;;GAKG;AACI,KAAK,UAAU,kCAAkC,CAAC,MAAkB;IACzE,MAAM,0BAA0B,GAAG,IAAI,oDAAuB,EAAE,CAAC;IACjE,MAAM,uBAAuB,GAAG,oDAAuB,CAAC,QAAQ,CAAC;IACjE,MAAM,YAAY,GAAG,kCAAc,CAAC,SAAS,EAAE,CAAC;IAEhD,MAAM,oBAAoB,GAAG;QAC3B,WAAW,EACT,uBAAuB,CAAC,OAAO,KAAK,EAAE;YACpC,CAAC,CAAC,uBAAuB,CAAC,KAAK;YAC/B,CAAC,CAAC,uBAAuB,CAAC,OAAO;QACrC,MAAM,EAAE,IAAA,2BAAgB,EAAC,MAAM,CAAC;QAChC,QAAQ,EAAE,YAAY;KACvB,CAAC;IAEF,MAAM,0BAA0B,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { FullConfig } from \"@playwright/test\";\nimport { PlaywrightServiceClient } from \"../utils/PlaywrightServiceClient.js\";\nimport { PlaywrightServiceConfig } from \"../common/playwrightServiceConfig.js\";\nimport { getTestRunConfig } from \"../utils/utils.js\";\nimport { CIInfoProvider } from \"../utils/cIInfoProvider.js\";\n\n/**\n * Initializes the Playwright workspaces by setting up authentication and creating a test run.\n *\n * @param config - The full Playwright configuration\n * @returns Promise that resolves when service initialization is complete\n */\nexport async function initializePlaywrightServiceTestRun(config: FullConfig): Promise<void> {\n const playwrightServiceApiClient = new PlaywrightServiceClient();\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n const ciConfigInfo = CIInfoProvider.getCIInfo();\n\n const testRunCreatePayload = {\n displayName:\n playwrightServiceConfig.runName === \"\"\n ? playwrightServiceConfig.runId\n : playwrightServiceConfig.runName,\n config: getTestRunConfig(config),\n ciConfig: ciConfigInfo,\n };\n\n await playwrightServiceApiClient.createOrUpdateTestRun(testRunCreatePayload);\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["/mnt/vss/_work/1/s/sdk/loadtesting/playwright/src/core/initializePlaywrightServiceTestRun.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { FullConfig } from \"@playwright/test\";\nimport { PlaywrightServiceClient } from \"../utils/PlaywrightServiceClient.js\";\nimport { PlaywrightServiceConfig } from \"../common/playwrightServiceConfig.js\";\nimport { getTestRunConfig } from \"../utils/utils.js\";\nimport { CIInfoProvider } from \"../utils/cIInfoProvider.js\";\n\n/**\n * Initializes the Playwright workspaces by setting up authentication and creating a test run.\n *\n * @param config - The full Playwright configuration\n * @returns Promise that resolves when service initialization is complete\n */\nexport async function initializePlaywrightServiceTestRun(config: FullConfig): Promise<void> {\n const playwrightServiceApiClient = new PlaywrightServiceClient();\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n const ciConfigInfo = CIInfoProvider.getCIInfo();\n\n const testRunCreatePayload = {\n displayName:\n playwrightServiceConfig.runName === \"\"\n ? playwrightServiceConfig.runId\n : playwrightServiceConfig.runName,\n config: getTestRunConfig(config),\n ciConfig: ciConfigInfo,\n };\n\n await playwrightServiceApiClient.createOrUpdateTestRun(testRunCreatePayload);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qCAAwC;AACxC,qCAAwC;AACxC,mBAAiC;AACjC,4BAA+B;AAQ/B,eAAsB,mCAAmC,QAAmC;AAC1F,QAAM,6BAA6B,IAAI,uDAAwB;AAC/D,QAAM,0BAA0B,uDAAwB;AACxD,QAAM,eAAe,qCAAe,UAAU;AAE9C,QAAM,uBAAuB;AAAA,IAC3B,aACE,wBAAwB,YAAY,KAChC,wBAAwB,QACxB,wBAAwB;AAAA,IAC9B,YAAQ,+BAAiB,MAAM;AAAA,IAC/B,UAAU;AAAA,EACZ;AAEA,QAAM,2BAA2B,sBAAsB,oBAAoB;AAC7E;",
6
+ "names": []
7
+ }
@@ -1,218 +1,179 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getConnectOptions = exports.createAzurePlaywrightConfig = void 0;
6
- const tslib_1 = require("tslib");
7
- const constants_js_1 = require("../common/constants.js");
8
- const customerConfig_js_1 = tslib_1.__importDefault(require("../common/customerConfig.js"));
9
- const playwrightServiceConfig_js_1 = require("../common/playwrightServiceConfig.js");
10
- const playwrightServiceEntra_js_1 = tslib_1.__importDefault(require("./playwrightServiceEntra.js"));
11
- const utils_js_1 = require("../utils/utils.js");
12
- const messages_js_1 = require("../common/messages.js");
13
- const playwrightServiceUtils_js_1 = require("./playwrightServiceUtils.js");
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var playwrightService_exports = {};
29
+ __export(playwrightService_exports, {
30
+ createAzurePlaywrightConfig: () => createAzurePlaywrightConfig,
31
+ getConnectOptions: () => getConnectOptions
32
+ });
33
+ module.exports = __toCommonJS(playwrightService_exports);
34
+ var import_constants = require("../common/constants.js");
35
+ var import_customerConfig = __toESM(require("../common/customerConfig.js"));
36
+ var import_playwrightServiceConfig = require("../common/playwrightServiceConfig.js");
37
+ var import_playwrightServiceEntra = __toESM(require("./playwrightServiceEntra.js"));
38
+ var import_utils = require("../utils/utils.js");
39
+ var import_messages = require("../common/messages.js");
40
+ var import_playwrightServiceUtils = require("./playwrightServiceUtils.js");
14
41
  const performOneTimeOperation = (options) => {
15
- const oneTimeOperationFlag = process.env[constants_js_1.InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] === "true";
16
- if (oneTimeOperationFlag)
17
- return;
18
- process.env[constants_js_1.InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] = "true";
19
- if (options?.serviceAuthType === constants_js_1.ServiceAuth.ACCESS_TOKEN) {
20
- (0, utils_js_1.warnIfAccessTokenCloseToExpiry)();
21
- }
42
+ const oneTimeOperationFlag = process.env[import_constants.InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] === "true";
43
+ if (oneTimeOperationFlag) return;
44
+ process.env[import_constants.InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] = "true";
45
+ if (options?.serviceAuthType === import_constants.ServiceAuth.ACCESS_TOKEN) {
46
+ (0, import_utils.warnIfAccessTokenCloseToExpiry)();
47
+ }
22
48
  };
23
- /**
24
- * @public
25
- *
26
- * Generate playwright configuration integrated with Azure Playwright.
27
- *
28
- * @param baseConfig - base playwright configuration
29
- * @param options - additional options for the service
30
- * @returns PlaywrightConfig
31
- *
32
- * @example
33
- * ```
34
- * import { defineConfig } from "playwright/test";
35
- * import { createAzurePlaywrightConfig } from "@azure/playwright";
36
- * import playwrightConfig from "./playwright.config";
37
- *
38
- * export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig));
39
- * ```
40
- *
41
- * @example
42
- * ```
43
- * import { defineConfig } from "playwright/test";
44
- * import { createAzurePlaywrightConfig, ServiceOS, ServiceAuth } from "@azure/playwright";
45
- * import playwrightConfig from "./playwright.config";
46
- * import { DefaultAzureCredential } from '@azure/identity';
47
- *
48
- * export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig, {
49
- * credential: new DefaultAzureCredential(),
50
- * serviceAuthType: ServiceAuth.ENTRA_ID,
51
- * os: ServiceOS.WINDOWS
52
- * }));
53
- * ```
54
- */
55
49
  const createAzurePlaywrightConfig = (baseConfig, options) => {
56
- (0, utils_js_1.validatePlaywrightVersion)();
57
- (0, utils_js_1.validateServiceUrl)();
58
- // Set environment variable to indicate user is using service config
59
- process.env[constants_js_1.InternalEnvironmentVariables.USING_SERVICE_CONFIG] = "true";
60
- const playwrightVersionInfo = (0, utils_js_1.getVersionInfo)((0, utils_js_1.getPlaywrightVersion)());
61
- const isMultipleGlobalFileSupported = playwrightVersionInfo.major >= 1 && playwrightVersionInfo.minor >= 49;
62
- if (options?.credential) {
63
- playwrightServiceEntra_js_1.default.entraIdAccessToken = options.credential;
64
- }
65
- // if global setup/teardown is string -
66
- // 1. if multiple global file is supported, convert it to array
67
- // 2. wrap playwright-service global setup/teardown with customer provided global setup/teardown
68
- // if global setup/teardown is array -
69
- // 1. if multiple global file is not supported, throw error
70
- // 2. append playwright-service global setup/teardown with customer provided global setup/teardown
71
- if (baseConfig && baseConfig.globalSetup) {
72
- if (typeof baseConfig.globalSetup === "string") {
73
- if (isMultipleGlobalFileSupported) {
74
- customerConfig_js_1.default.globalSetup = [baseConfig.globalSetup];
75
- }
76
- else {
77
- customerConfig_js_1.default.globalSetup = baseConfig.globalSetup;
78
- }
79
- }
80
- else {
81
- if (!isMultipleGlobalFileSupported) {
82
- throw new Error(messages_js_1.ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message);
83
- }
84
- customerConfig_js_1.default.globalSetup = baseConfig.globalSetup;
85
- }
86
- }
87
- if (baseConfig && baseConfig.globalTeardown) {
88
- if (typeof baseConfig.globalTeardown === "string") {
89
- if (isMultipleGlobalFileSupported) {
90
- customerConfig_js_1.default.globalTeardown = [baseConfig.globalTeardown];
91
- }
92
- else {
93
- customerConfig_js_1.default.globalTeardown = baseConfig.globalTeardown;
94
- }
95
- }
96
- else {
97
- if (!isMultipleGlobalFileSupported) {
98
- throw new Error(messages_js_1.ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message);
99
- }
100
- customerConfig_js_1.default.globalTeardown = baseConfig.globalTeardown;
101
- }
50
+ (0, import_utils.validatePlaywrightVersion)();
51
+ (0, import_utils.validateServiceUrl)();
52
+ process.env[import_constants.InternalEnvironmentVariables.USING_SERVICE_CONFIG] = "true";
53
+ const playwrightVersionInfo = (0, import_utils.getVersionInfo)((0, import_utils.getPlaywrightVersion)());
54
+ const isMultipleGlobalFileSupported = playwrightVersionInfo.major >= 1 && playwrightVersionInfo.minor >= 49;
55
+ if (options?.credential) {
56
+ import_playwrightServiceEntra.default.entraIdAccessToken = options.credential;
57
+ }
58
+ if (baseConfig && baseConfig.globalSetup) {
59
+ if (typeof baseConfig.globalSetup === "string") {
60
+ if (isMultipleGlobalFileSupported) {
61
+ import_customerConfig.default.globalSetup = [baseConfig.globalSetup];
62
+ } else {
63
+ import_customerConfig.default.globalSetup = baseConfig.globalSetup;
64
+ }
65
+ } else {
66
+ if (!isMultipleGlobalFileSupported) {
67
+ throw new Error(
68
+ import_messages.ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message
69
+ );
70
+ }
71
+ import_customerConfig.default.globalSetup = baseConfig.globalSetup;
102
72
  }
103
- const playwrightServiceConfig = playwrightServiceConfig_js_1.PlaywrightServiceConfig.instance;
104
- playwrightServiceConfig.setOptions(options);
105
- playwrightServiceConfig.serviceAuthType =
106
- options?.serviceAuthType || constants_js_1.DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;
107
- const globalFunctions = {};
108
- if (options?.serviceAuthType === constants_js_1.ServiceAuth.ACCESS_TOKEN) {
109
- // mpt PAT requested and set by the customer, no need to setup entra lifecycle handlers
110
- (0, utils_js_1.validateMptPAT)(utils_js_1.exitWithFailureMessage);
73
+ }
74
+ if (baseConfig && baseConfig.globalTeardown) {
75
+ if (typeof baseConfig.globalTeardown === "string") {
76
+ if (isMultipleGlobalFileSupported) {
77
+ import_customerConfig.default.globalTeardown = [baseConfig.globalTeardown];
78
+ } else {
79
+ import_customerConfig.default.globalTeardown = baseConfig.globalTeardown;
80
+ }
81
+ } else {
82
+ if (!isMultipleGlobalFileSupported) {
83
+ throw new Error(
84
+ import_messages.ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message
85
+ );
86
+ }
87
+ import_customerConfig.default.globalTeardown = baseConfig.globalTeardown;
111
88
  }
112
- // If multiple global file is supported, append playwright-service global setup/teardown with customer provided global setup/teardown
113
- if (isMultipleGlobalFileSupported) {
114
- globalFunctions.globalSetup = [];
115
- globalFunctions.globalTeardown = [];
116
- if (customerConfig_js_1.default.globalSetup) {
117
- globalFunctions.globalSetup.push(...customerConfig_js_1.default.globalSetup);
118
- }
119
- if (customerConfig_js_1.default.globalTeardown) {
120
- globalFunctions.globalTeardown.push(...customerConfig_js_1.default.globalTeardown);
121
- }
122
- globalFunctions.globalSetup.push(playwrightServiceUtils_js_1.globalPaths.setup);
123
- globalFunctions.globalTeardown.push(playwrightServiceUtils_js_1.globalPaths.teardown);
89
+ }
90
+ const playwrightServiceConfig = import_playwrightServiceConfig.PlaywrightServiceConfig.instance;
91
+ playwrightServiceConfig.setOptions(options);
92
+ playwrightServiceConfig.serviceAuthType = options?.serviceAuthType || import_constants.DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;
93
+ const globalFunctions = {};
94
+ if (options?.serviceAuthType === import_constants.ServiceAuth.ACCESS_TOKEN) {
95
+ (0, import_utils.validateMptPAT)(import_utils.exitWithFailureMessage);
96
+ }
97
+ if (isMultipleGlobalFileSupported) {
98
+ globalFunctions.globalSetup = [];
99
+ globalFunctions.globalTeardown = [];
100
+ if (import_customerConfig.default.globalSetup) {
101
+ globalFunctions.globalSetup.push(...import_customerConfig.default.globalSetup);
124
102
  }
125
- else {
126
- // If multiple global file is not supported, wrap playwright-service global setup/teardown with customer provided global setup/teardown
127
- globalFunctions.globalSetup = playwrightServiceUtils_js_1.globalPaths.setup;
128
- globalFunctions.globalTeardown = playwrightServiceUtils_js_1.globalPaths.teardown;
103
+ if (import_customerConfig.default.globalTeardown) {
104
+ globalFunctions.globalTeardown.push(...import_customerConfig.default.globalTeardown);
129
105
  }
130
- performOneTimeOperation(options);
131
- if (!process.env[constants_js_1.InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED]) {
132
- process.env[constants_js_1.InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] = "true";
133
- console.log("\nRunning tests using Playwright workspaces.");
134
- }
135
- return {
136
- use: {
137
- connectOptions: {
138
- wsEndpoint: (0, utils_js_1.getServiceWSEndpoint)(playwrightServiceConfig.runId, playwrightServiceConfig.serviceOs, playwrightServiceConfig.apiVersion),
139
- headers: {
140
- Authorization: `Bearer ${(0, utils_js_1.getAccessToken)()}`,
141
- "x-ms-package-version": `@azure/playwright/${(0, utils_js_1.getPackageVersion)()}`,
142
- },
143
- timeout: playwrightServiceConfig.connectTimeout,
144
- exposeNetwork: playwrightServiceConfig.exposeNetwork,
145
- slowMo: playwrightServiceConfig.slowMo,
146
- },
106
+ globalFunctions.globalSetup.push(import_playwrightServiceUtils.globalPaths.setup);
107
+ globalFunctions.globalTeardown.push(import_playwrightServiceUtils.globalPaths.teardown);
108
+ } else {
109
+ globalFunctions.globalSetup = import_playwrightServiceUtils.globalPaths.setup;
110
+ globalFunctions.globalTeardown = import_playwrightServiceUtils.globalPaths.teardown;
111
+ }
112
+ performOneTimeOperation(options);
113
+ if (!process.env[import_constants.InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED]) {
114
+ process.env[import_constants.InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] = "true";
115
+ console.log("\nRunning tests using Playwright workspaces.");
116
+ }
117
+ return {
118
+ use: {
119
+ connectOptions: {
120
+ wsEndpoint: (0, import_utils.getServiceWSEndpoint)(
121
+ playwrightServiceConfig.runId,
122
+ playwrightServiceConfig.serviceOs,
123
+ playwrightServiceConfig.apiVersion
124
+ ),
125
+ headers: {
126
+ Authorization: `Bearer ${(0, import_utils.getAccessToken)()}`,
127
+ "x-ms-package-version": `@azure/playwright/${(0, import_utils.getPackageVersion)()}`
147
128
  },
148
- ...globalFunctions,
149
- };
129
+ timeout: playwrightServiceConfig.connectTimeout,
130
+ exposeNetwork: playwrightServiceConfig.exposeNetwork,
131
+ slowMo: playwrightServiceConfig.slowMo
132
+ }
133
+ },
134
+ ...globalFunctions
135
+ };
150
136
  };
151
- exports.createAzurePlaywrightConfig = createAzurePlaywrightConfig;
152
- /**
153
- * @public
154
- *
155
- * Get connect options required to connect to Azure Playwright's cloud hosted browsers.
156
- *
157
- * @param options - additional options for the service
158
- * @returns BrowserConnectOptions
159
- *
160
- * @example
161
- * ```
162
- * import playwright, { test, expect, BrowserType } from "@playwright/test";
163
- * import { getConnectOptions } from "@azure/playwright";
164
- *
165
- * test('has title', async ({ browserName }) => {
166
- * const { wsEndpoint, options } = await getConnectOptions();
167
- * const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);
168
- * const context = await browser.newContext();
169
- * const page = await context.newPage();
170
- *
171
- * await page.goto('https://playwright.dev/');
172
- * await expect(page).toHaveTitle(/Playwright/);
173
- *
174
- * await page.close();
175
- * await context.close();
176
- * await browser.close();
177
- * });
178
- * ```
179
- */
180
137
  const getConnectOptions = async (options) => {
181
- const playwrightServiceConfig = playwrightServiceConfig_js_1.PlaywrightServiceConfig.instance;
182
- playwrightServiceConfig.setOptions(options, true);
183
- performOneTimeOperation(options);
184
- playwrightServiceConfig.serviceAuthType =
185
- options?.serviceAuthType || constants_js_1.DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;
186
- let token;
187
- if (playwrightServiceConfig.serviceAuthType === constants_js_1.ServiceAuth.ENTRA_ID) {
188
- if (!options?.credential) {
189
- throw new Error(messages_js_1.ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);
190
- }
191
- playwrightServiceEntra_js_1.default.entraIdAccessToken = options.credential;
192
- token = await (0, utils_js_1.fetchOrValidateAccessToken)(options.credential);
193
- }
194
- else if (playwrightServiceConfig.serviceAuthType === constants_js_1.ServiceAuth.ACCESS_TOKEN) {
195
- (0, utils_js_1.validateMptPAT)(utils_js_1.throwErrorWithFailureMessage);
196
- token = (0, utils_js_1.getAccessToken)();
138
+ const playwrightServiceConfig = import_playwrightServiceConfig.PlaywrightServiceConfig.instance;
139
+ playwrightServiceConfig.setOptions(options, true);
140
+ performOneTimeOperation(options);
141
+ playwrightServiceConfig.serviceAuthType = options?.serviceAuthType || import_constants.DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;
142
+ let token;
143
+ if (playwrightServiceConfig.serviceAuthType === import_constants.ServiceAuth.ENTRA_ID) {
144
+ if (!options?.credential) {
145
+ throw new Error(import_messages.ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);
197
146
  }
198
- else {
199
- throw new Error(messages_js_1.ServiceErrorMessageConstants.INVALID_AUTH_TYPE_ERROR.message);
147
+ import_playwrightServiceEntra.default.entraIdAccessToken = options.credential;
148
+ token = await (0, import_utils.fetchOrValidateAccessToken)(options.credential);
149
+ } else if (playwrightServiceConfig.serviceAuthType === import_constants.ServiceAuth.ACCESS_TOKEN) {
150
+ (0, import_utils.validateMptPAT)(import_utils.throwErrorWithFailureMessage);
151
+ token = (0, import_utils.getAccessToken)();
152
+ } else {
153
+ throw new Error(import_messages.ServiceErrorMessageConstants.INVALID_AUTH_TYPE_ERROR.message);
154
+ }
155
+ if (!token) {
156
+ throw new Error(import_messages.ServiceErrorMessageConstants.NO_AUTH_ERROR_PAT_TOKEN.message);
157
+ }
158
+ return {
159
+ wsEndpoint: (0, import_utils.getServiceWSEndpoint)(
160
+ playwrightServiceConfig.runId,
161
+ playwrightServiceConfig.serviceOs,
162
+ playwrightServiceConfig.apiVersion
163
+ ),
164
+ options: {
165
+ headers: {
166
+ Authorization: `Bearer ${token}`,
167
+ "x-ms-package-version": `@azure/playwright/${(0, import_utils.getPackageVersion)()}`
168
+ },
169
+ timeout: playwrightServiceConfig.connectTimeout,
170
+ exposeNetwork: playwrightServiceConfig.exposeNetwork,
171
+ slowMo: playwrightServiceConfig.slowMo
200
172
  }
201
- if (!token) {
202
- throw new Error(messages_js_1.ServiceErrorMessageConstants.NO_AUTH_ERROR_PAT_TOKEN.message);
203
- }
204
- return {
205
- wsEndpoint: (0, utils_js_1.getServiceWSEndpoint)(playwrightServiceConfig.runId, playwrightServiceConfig.serviceOs, playwrightServiceConfig.apiVersion),
206
- options: {
207
- headers: {
208
- Authorization: `Bearer ${token}`,
209
- "x-ms-package-version": `@azure/playwright/${(0, utils_js_1.getPackageVersion)()}`,
210
- },
211
- timeout: playwrightServiceConfig.connectTimeout,
212
- exposeNetwork: playwrightServiceConfig.exposeNetwork,
213
- slowMo: playwrightServiceConfig.slowMo,
214
- },
215
- };
173
+ };
216
174
  };
217
- exports.getConnectOptions = getConnectOptions;
218
- //# sourceMappingURL=playwrightService.js.map
175
+ // Annotate the CommonJS export names for ESM import in node:
176
+ 0 && (module.exports = {
177
+ createAzurePlaywrightConfig,
178
+ getConnectOptions
179
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"playwrightService.js","sourceRoot":"","sources":["../../../src/core/playwrightService.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,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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
+ {
2
+ "version": 3,
3
+ "sources": ["/mnt/vss/_work/1/s/sdk/loadtesting/playwright/src/core/playwrightService.ts"],
4
+ "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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAIO;AACP,4BAA2B;AAC3B,qCAAwC;AACxC,oCAAmC;AAEnC,mBAaO;AACP,sBAA6C;AAE7C,oCAA4B;AAE5B,MAAM,0BAA0B,CAAC,YAAuD;AACtF,QAAM,uBACJ,QAAQ,IAAI,8CAA6B,uBAAuB,MAAM;AACxE,MAAI,qBAAsB;AAC1B,UAAQ,IAAI,8CAA6B,uBAAuB,IAAI;AACpE,MAAI,SAAS,oBAAoB,6BAAY,cAAc;AACzD,qDAA+B;AAAA,EACjC;AACF;AAkCA,MAAM,8BAA8B,CAClC,YACA,YACyB;AACzB,8CAA0B;AAC1B,uCAAmB;AAGnB,UAAQ,IAAI,8CAA6B,oBAAoB,IAAI;AACjE,QAAM,4BAAwB,iCAAe,mCAAqB,CAAC;AACnE,QAAM,gCACJ,sBAAsB,SAAS,KAAK,sBAAsB,SAAS;AACrE,MAAI,SAAS,YAAY;AACvB,kCAAAA,QAAuB,qBAAqB,QAAQ;AAAA,EACtD;AASA,MAAI,cAAc,WAAW,aAAa;AACxC,QAAI,OAAO,WAAW,gBAAgB,UAAU;AAC9C,UAAI,+BAA+B;AACjC,8BAAAC,QAAe,cAAc,CAAC,WAAW,WAAW;AAAA,MACtD,OAAO;AACL,8BAAAA,QAAe,cAAc,WAAW;AAAA,MAC1C;AAAA,IACF,OAAO;AACL,UAAI,CAAC,+BAA+B;AAClC,cAAM,IAAI;AAAA,UACR,6CAA6B,6CAA6C;AAAA,QAC5E;AAAA,MACF;AACA,4BAAAA,QAAe,cAAc,WAAW;AAAA,IAC1C;AAAA,EACF;AAEA,MAAI,cAA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