@azure/create-playwright 1.0.0-beta.3 → 1.0.0
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 +2 -2
- package/dist/commonjs/constants.js +1 -1
- package/dist/commonjs/constants.js.map +1 -1
- package/dist/commonjs/initialize.d.ts +2 -2
- package/dist/commonjs/initialize.d.ts.map +1 -1
- package/dist/commonjs/initialize.js +12 -12
- package/dist/commonjs/initialize.js.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/initialize.d.ts +2 -2
- package/dist/esm/initialize.d.ts.map +1 -1
- package/dist/esm/initialize.js +12 -12
- package/dist/esm/initialize.js.map +1 -1
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Azure Playwright
|
|
1
|
+
# Azure Playwright
|
|
2
2
|
|
|
3
|
-
Azure Playwright is a fully managed service that uses the cloud to enable you to run Playwright tests with much higher parallelization across different operating system-browser combinations simultaneously. This means faster test runs with broader scenario coverage, which helps speed up delivery of features without sacrificing quality.
|
|
3
|
+
Azure Playwright is a fully managed service that uses the cloud to enable you to run Playwright tests with much higher parallelization across different operating system-browser combinations simultaneously. This means faster test runs with broader scenario coverage, which helps speed up delivery of features without sacrificing quality. With Playwright Workspaces, you can release features faster and more confidently.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ exports.ErrorMessages = {
|
|
|
16
16
|
UNSUPPORTED_CONFIGURATION_FILE: "The playwright configuration file passed is not supported.",
|
|
17
17
|
};
|
|
18
18
|
exports.Messages = {
|
|
19
|
-
CAN_OVERRIDE_MESSAGE: "There's already a playwright
|
|
19
|
+
CAN_OVERRIDE_MESSAGE: "There's already a playwright workspaces configuration file present. Do you want to overwrite it?",
|
|
20
20
|
CONFIRMATION_FOR_EXIT_MESSAGE: "You won't be able to install and setup up the service without overwriting the existing configuration file. Do you still want to exit the setup process?",
|
|
21
21
|
SETUP_PROCESS_EXIT_MESSAGE: "Exiting the service setup process.",
|
|
22
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIrB,QAAA,SAAS,GAAG;IACvB,UAAU,EAAE,YAAwB;IACpC,UAAU,EAAE,YAAwB;CACrC,CAAC;AAEW,QAAA,UAAU,GAAG;IACxB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEW,QAAA,aAAa,GAAG;IAC3B,2BAA2B,EACzB,2IAA2I;IAC7I,8BAA8B,EAAE,4DAA4D;CAC7F,CAAC;AAEW,QAAA,QAAQ,GAAG;IACtB,oBAAoB,EAClB
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIrB,QAAA,SAAS,GAAG;IACvB,UAAU,EAAE,YAAwB;IACpC,UAAU,EAAE,YAAwB;CACrC,CAAC;AAEW,QAAA,UAAU,GAAG;IACxB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEW,QAAA,aAAa,GAAG;IAC3B,2BAA2B,EACzB,2IAA2I;IAC7I,8BAA8B,EAAE,4DAA4D;CAC7F,CAAC;AAEW,QAAA,QAAQ,GAAG;IACtB,oBAAoB,EAClB,kGAAkG;IACpG,6BAA6B,EAC3B,yJAAyJ;IAC3J,0BAA0B,EAAE,oCAAoC;CACjE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Language } from \"./types.js\";\n\nexport const Languages = {\n TypeScript: \"TypeScript\" as Language,\n JavaScript: \"JavaScript\" as Language,\n};\n\nexport const Extensions = {\n TypeScript: \".ts\",\n JavaScript: \".js\",\n};\n\nexport const ErrorMessages = {\n NO_CONFIGURATION_FILE_FOUND:\n \"Could not find a playwright configuration file in the current directory. Please use --config parameter to specify the configuration file.\",\n UNSUPPORTED_CONFIGURATION_FILE: \"The playwright configuration file passed is not supported.\",\n};\n\nexport const Messages = {\n CAN_OVERRIDE_MESSAGE:\n \"There's already a playwright workspaces configuration file present. Do you want to overwrite it?\",\n CONFIRMATION_FOR_EXIT_MESSAGE:\n \"You won't be able to install and setup up the service without overwriting the existing configuration file. Do you still want to exit the setup process?\",\n SETUP_PROCESS_EXIT_MESSAGE: \"Exiting the service setup process.\",\n};\n"]}
|
|
@@ -10,7 +10,7 @@ export declare class PlaywrightServiceInitialize {
|
|
|
10
10
|
private displayAdditionalInformation;
|
|
11
11
|
private installServicePackage;
|
|
12
12
|
private createServiceConfig;
|
|
13
|
-
private
|
|
14
|
-
private
|
|
13
|
+
private createAzurePlaywrightConfigContent;
|
|
14
|
+
private createAzurePlaywrightConfigFileName;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=initialize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/initialize.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGV,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AAmBpB,qBAAa,2BAA2B;IACtC,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,eAAe,CAAiB;gBAE5B,WAAW,EAAE,2BAA2B;IAK7C,4BAA4B,QAAa,OAAO,CAAC,IAAI,CAAC,CAM3D;IAEF,OAAO,CAAC,8BAA8B,CAUpC;IAEF,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,iCAAiC,CAEvC;IAEF,OAAO,CAAC,4BAA4B,CAclC;IAEF,OAAO,CAAC,qBAAqB,CAM3B;IAEF,OAAO,CAAC,mBAAmB,CAKzB;IAEF,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/initialize.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGV,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AAmBpB,qBAAa,2BAA2B;IACtC,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,eAAe,CAAiB;gBAE5B,WAAW,EAAE,2BAA2B;IAK7C,4BAA4B,QAAa,OAAO,CAAC,IAAI,CAAC,CAM3D;IAEF,OAAO,CAAC,8BAA8B,CAUpC;IAEF,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,iCAAiC,CAEvC;IAEF,OAAO,CAAC,4BAA4B,CAclC;IAEF,OAAO,CAAC,qBAAqB,CAM3B;IAEF,OAAO,CAAC,mBAAmB,CAKzB;IAEF,OAAO,CAAC,kCAAkC,CAqCxC;IAEF,OAAO,CAAC,mCAAmC,CAEzC;CACH"}
|
|
@@ -55,14 +55,14 @@ class PlaywrightServiceInitialize {
|
|
|
55
55
|
process.exit(0);
|
|
56
56
|
};
|
|
57
57
|
isServiceConfigFileAlreadyPresent = () => {
|
|
58
|
-
return node_fs_1.default.existsSync(this.
|
|
58
|
+
return node_fs_1.default.existsSync(this.createAzurePlaywrightConfigFileName());
|
|
59
59
|
};
|
|
60
60
|
displayAdditionalInformation = () => {
|
|
61
|
-
const runCommandParallelWorkers = this._packageManager.runCommand("playwright", `test -c ${this.
|
|
62
|
-
console.log(`\n\nTo run playwrights tests using Playwright
|
|
61
|
+
const runCommandParallelWorkers = this._packageManager.runCommand("playwright", `test -c ${this.createAzurePlaywrightConfigFileName()} --workers=20`);
|
|
62
|
+
console.log(`\n\nTo run playwrights tests using Playwright Workspaces\n`);
|
|
63
63
|
console.log(`\t${runCommandParallelWorkers}\n`);
|
|
64
64
|
console.log("Getting Started - https://aka.ms/pww/docs/quickstart\n");
|
|
65
|
-
console.log("If you're already using the
|
|
65
|
+
console.log("If you're already using the Playwright Workspaces, please review the quickstart guide [https://aka.ms/pww/docs/quickstart] to ensure your tests continue running smoothly.");
|
|
66
66
|
};
|
|
67
67
|
installServicePackage = async () => {
|
|
68
68
|
const command = this._packageManager.installDevDependencyCommand("@azure/playwright @azure/identity");
|
|
@@ -70,20 +70,20 @@ class PlaywrightServiceInitialize {
|
|
|
70
70
|
await (0, utils_js_1.executeCommand)(command);
|
|
71
71
|
};
|
|
72
72
|
createServiceConfig = async () => {
|
|
73
|
-
const serviceConfigFile = this.
|
|
74
|
-
const serviceConfigFileContent = this.
|
|
73
|
+
const serviceConfigFile = this.createAzurePlaywrightConfigFileName();
|
|
74
|
+
const serviceConfigFileContent = this.createAzurePlaywrightConfigContent();
|
|
75
75
|
await node_fs_1.default.promises.writeFile(serviceConfigFile, serviceConfigFileContent);
|
|
76
76
|
console.log(`Success! Created service configuration file - ${serviceConfigFile}`);
|
|
77
77
|
};
|
|
78
|
-
|
|
78
|
+
createAzurePlaywrightConfigContent = () => {
|
|
79
79
|
const customerConfigFileName = (0, utils_js_1.getFileReferenceForImport)(this._setupConfig.playwrightConfigFile);
|
|
80
80
|
const importCommandTypeScript = `import { defineConfig } from '@playwright/test';
|
|
81
|
-
import {
|
|
81
|
+
import { createAzurePlaywrightConfig, ServiceOS } from '@azure/playwright';
|
|
82
82
|
import { DefaultAzureCredential } from '@azure/identity';
|
|
83
83
|
import config from '${customerConfigFileName}';
|
|
84
84
|
`;
|
|
85
85
|
const importCommandJavaScript = `const { defineConfig } = require('@playwright/test');
|
|
86
|
-
const {
|
|
86
|
+
const { createAzurePlaywrightConfig, ServiceOS } = require('@azure/playwright');
|
|
87
87
|
const { DefaultAzureCredential } = require('@azure/identity');
|
|
88
88
|
const config = require('${customerConfigFileName}');
|
|
89
89
|
`;
|
|
@@ -95,9 +95,9 @@ const config = require('${customerConfigFileName}');
|
|
|
95
95
|
/* Learn more about service configuration at https://aka.ms/pww/docs/config */
|
|
96
96
|
export default defineConfig(
|
|
97
97
|
config,
|
|
98
|
-
|
|
98
|
+
createAzurePlaywrightConfig(config, {
|
|
99
99
|
exposeNetwork: '<loopback>',
|
|
100
|
-
|
|
100
|
+
connectTimeout: 3 * 60 * 1000, // 3 minutes
|
|
101
101
|
os: ServiceOS.LINUX,
|
|
102
102
|
credential: new DefaultAzureCredential(),
|
|
103
103
|
})
|
|
@@ -105,7 +105,7 @@ export default defineConfig(
|
|
|
105
105
|
`;
|
|
106
106
|
return content;
|
|
107
107
|
};
|
|
108
|
-
|
|
108
|
+
createAzurePlaywrightConfigFileName = () => {
|
|
109
109
|
return "playwright.service.config" + constants_js_1.Extensions[this._setupConfig.projectLanguage];
|
|
110
110
|
};
|
|
111
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../src/initialize.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,8DAA8B;AAC9B,8DAAyB;AACzB,iDAAiE;AAMjE,yCAAuE;AACvE,2DAAwD;AAExD,MAAM,SAAS,GAAmB;IAChC;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,uBAAQ,CAAC,oBAAoB;QACtC,OAAO,EAAE,IAAI;KACd;IACD;QACE,IAAI,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAClD,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,uBAAQ,CAAC,6BAA6B;QAC/C,OAAO,EAAE,IAAI;KACd;CACF,CAAC;AAEF,MAAa,2BAA2B;IAC9B,YAAY,CAA8B;IAC1C,eAAe,CAAiB;IAExC,YAAY,WAAwC;QAClD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,eAAe,GAAG,IAAA,qCAAiB,GAAE,CAAC;IAC7C,CAAC;IAEM,4BAA4B,GAAG,KAAK,IAAmB,EAAE;QAC9D,MAAM,mCAAmC,GAAG,MAAM,IAAI,CAAC,8BAA8B,EAAE,C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iBAAiB,EAAE,CAAC,CAAC;IACpF,CAAC,CAAC;IAEM,kCAAkC,GAAG,GAAW,EAAE;QACxD,MAAM,sBAAsB,GAAG,IAAA,oCAAyB,EACtD,IAAI,CAAC,YAAY,CAAC,oBAAoB,CACvC,CAAC;QAEF,MAAM,uBAAuB,GAAG;;;sBAGd,sBAAsB;CAC3C,CAAC;QAEE,MAAM,uBAAuB,GAAG;;;0BAGV,sBAAsB;CAC/C,CAAC;QAEE,MAAM,aAAa,GACjB,IAAI,CAAC,YAAY,CAAC,eAAe,KAAK,wBAAS,CAAC,UAAU;YACxD,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,uBAAuB,CAAC;QAE9B,MAAM,OAAO,GACX,aAAa;YACb;;;;;;;;;;;CAWL,CAAC;QACE,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEM,mCAAmC,GAAG,GAAW,EAAE;QACzD,OAAO,2BAA2B,GAAG,yBAAU,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IACrF,CAAC,CAAC;CACH;AA9GD,kEA8GC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PromptObject } from \"prompts\";\nimport prompts from \"prompts\";\nimport fs from \"node:fs\";\nimport { Extensions, Languages, Messages } from \"./constants.js\";\nimport type {\n OverridePromptResponse,\n PackageManager,\n PlaywrightServiceInitConfig,\n} from \"./types.js\";\nimport { executeCommand, getFileReferenceForImport } from \"./utils.js\";\nimport { getPackageManager } from \"./packageManager.js\";\n\nconst questions: PromptObject[] = [\n {\n type: \"confirm\",\n name: \"canOverride\",\n message: Messages.CAN_OVERRIDE_MESSAGE,\n initial: true,\n },\n {\n type: (prev: boolean) => (prev ? null : \"confirm\"),\n name: \"confirmationForExit\",\n message: Messages.CONFIRMATION_FOR_EXIT_MESSAGE,\n initial: true,\n },\n];\n\nexport class PlaywrightServiceInitialize {\n private _setupConfig: PlaywrightServiceInitConfig;\n private _packageManager: PackageManager;\n\n constructor(setupConfig: PlaywrightServiceInitConfig) {\n this._setupConfig = setupConfig;\n this._packageManager = getPackageManager();\n }\n\n public addServiceSupportToTestSuite = async (): Promise<void> => {\n const canProceedWithServiceInitialization = await this.checkIfServiceConfigCanBeAdded(); // if service config already present, ask user for overwrite permission\n if (!canProceedWithServiceInitialization) return;\n await this.installServicePackage(); // install service packages\n await this.createServiceConfig(); // create service config file\n this.displayAdditionalInformation(); // display additional information\n };\n\n private checkIfServiceConfigCanBeAdded = async (): Promise<boolean> => {\n if (!this.isServiceConfigFileAlreadyPresent()) return true;\n const response = (await prompts.prompt(questions, {\n onCancel: this.promptOnCancel,\n })) as OverridePromptResponse;\n if (response.canOverride) return true;\n if (!response.confirmationForExit) return this.checkIfServiceConfigCanBeAdded();\n\n console.log(`\\n${Messages.SETUP_PROCESS_EXIT_MESSAGE}`);\n return false;\n };\n\n private promptOnCancel = (): never => {\n process.exit(0);\n };\n\n private isServiceConfigFileAlreadyPresent = (): boolean => {\n return fs.existsSync(this.createAzurePlaywrightConfigFileName());\n };\n\n private displayAdditionalInformation = (): void => {\n const runCommandParallelWorkers = this._packageManager.runCommand(\n \"playwright\",\n `test -c ${this.createAzurePlaywrightConfigFileName()} --workers=20`,\n );\n\n console.log(`\\n\\nTo run playwrights tests using Playwright Workspaces\\n`);\n console.log(`\\t${runCommandParallelWorkers}\\n`);\n\n console.log(\"Getting Started - https://aka.ms/pww/docs/quickstart\\n\");\n\n console.log(\n \"If you're already using the Playwright Workspaces, please review the quickstart guide [https://aka.ms/pww/docs/quickstart] to ensure your tests continue running smoothly.\",\n );\n };\n\n private installServicePackage = async (): Promise<void> => {\n const command = this._packageManager.installDevDependencyCommand(\n \"@azure/playwright @azure/identity\",\n );\n console.log(`Installing Service package (${command})`);\n await executeCommand(command);\n };\n\n private createServiceConfig = async (): Promise<void> => {\n const serviceConfigFile = this.createAzurePlaywrightConfigFileName();\n const serviceConfigFileContent = this.createAzurePlaywrightConfigContent();\n await fs.promises.writeFile(serviceConfigFile, serviceConfigFileContent);\n console.log(`Success! Created service configuration file - ${serviceConfigFile}`);\n };\n\n private createAzurePlaywrightConfigContent = (): string => {\n const customerConfigFileName = getFileReferenceForImport(\n this._setupConfig.playwrightConfigFile,\n );\n\n const importCommandTypeScript = `import { defineConfig } from '@playwright/test';\nimport { createAzurePlaywrightConfig, ServiceOS } from '@azure/playwright';\nimport { DefaultAzureCredential } from '@azure/identity';\nimport config from '${customerConfigFileName}';\n`;\n\n const importCommandJavaScript = `const { defineConfig } = require('@playwright/test');\nconst { createAzurePlaywrightConfig, ServiceOS } = require('@azure/playwright');\nconst { DefaultAzureCredential } = require('@azure/identity');\nconst config = require('${customerConfigFileName}');\n`;\n\n const importCommand =\n this._setupConfig.projectLanguage === Languages.TypeScript\n ? importCommandTypeScript\n : importCommandJavaScript;\n\n const content =\n importCommand +\n `\n/* Learn more about service configuration at https://aka.ms/pww/docs/config */\nexport default defineConfig(\n config,\n createAzurePlaywrightConfig(config, {\n exposeNetwork: '<loopback>',\n connectTimeout: 3 * 60 * 1000, // 3 minutes\n os: ServiceOS.LINUX,\n credential: new DefaultAzureCredential(),\n })\n);\n`;\n return content;\n };\n\n private createAzurePlaywrightConfigFileName = (): string => {\n return \"playwright.service.config\" + Extensions[this._setupConfig.projectLanguage];\n };\n}\n"]}
|
package/dist/esm/constants.js
CHANGED
|
@@ -13,7 +13,7 @@ export const ErrorMessages = {
|
|
|
13
13
|
UNSUPPORTED_CONFIGURATION_FILE: "The playwright configuration file passed is not supported.",
|
|
14
14
|
};
|
|
15
15
|
export const Messages = {
|
|
16
|
-
CAN_OVERRIDE_MESSAGE: "There's already a playwright
|
|
16
|
+
CAN_OVERRIDE_MESSAGE: "There's already a playwright workspaces configuration file present. Do you want to overwrite it?",
|
|
17
17
|
CONFIRMATION_FOR_EXIT_MESSAGE: "You won't be able to install and setup up the service without overwriting the existing configuration file. Do you still want to exit the setup process?",
|
|
18
18
|
SETUP_PROCESS_EXIT_MESSAGE: "Exiting the service setup process.",
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,YAAwB;IACpC,UAAU,EAAE,YAAwB;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,2BAA2B,EACzB,2IAA2I;IAC7I,8BAA8B,EAAE,4DAA4D;CAC7F,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,oBAAoB,EAClB
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,YAAwB;IACpC,UAAU,EAAE,YAAwB;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,2BAA2B,EACzB,2IAA2I;IAC7I,8BAA8B,EAAE,4DAA4D;CAC7F,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,oBAAoB,EAClB,kGAAkG;IACpG,6BAA6B,EAC3B,yJAAyJ;IAC3J,0BAA0B,EAAE,oCAAoC;CACjE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Language } from \"./types.js\";\n\nexport const Languages = {\n TypeScript: \"TypeScript\" as Language,\n JavaScript: \"JavaScript\" as Language,\n};\n\nexport const Extensions = {\n TypeScript: \".ts\",\n JavaScript: \".js\",\n};\n\nexport const ErrorMessages = {\n NO_CONFIGURATION_FILE_FOUND:\n \"Could not find a playwright configuration file in the current directory. Please use --config parameter to specify the configuration file.\",\n UNSUPPORTED_CONFIGURATION_FILE: \"The playwright configuration file passed is not supported.\",\n};\n\nexport const Messages = {\n CAN_OVERRIDE_MESSAGE:\n \"There's already a playwright workspaces configuration file present. Do you want to overwrite it?\",\n CONFIRMATION_FOR_EXIT_MESSAGE:\n \"You won't be able to install and setup up the service without overwriting the existing configuration file. Do you still want to exit the setup process?\",\n SETUP_PROCESS_EXIT_MESSAGE: \"Exiting the service setup process.\",\n};\n"]}
|
package/dist/esm/initialize.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class PlaywrightServiceInitialize {
|
|
|
10
10
|
private displayAdditionalInformation;
|
|
11
11
|
private installServicePackage;
|
|
12
12
|
private createServiceConfig;
|
|
13
|
-
private
|
|
14
|
-
private
|
|
13
|
+
private createAzurePlaywrightConfigContent;
|
|
14
|
+
private createAzurePlaywrightConfigFileName;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=initialize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/initialize.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGV,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AAmBpB,qBAAa,2BAA2B;IACtC,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,eAAe,CAAiB;gBAE5B,WAAW,EAAE,2BAA2B;IAK7C,4BAA4B,QAAa,OAAO,CAAC,IAAI,CAAC,CAM3D;IAEF,OAAO,CAAC,8BAA8B,CAUpC;IAEF,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,iCAAiC,CAEvC;IAEF,OAAO,CAAC,4BAA4B,CAclC;IAEF,OAAO,CAAC,qBAAqB,CAM3B;IAEF,OAAO,CAAC,mBAAmB,CAKzB;IAEF,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/initialize.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGV,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AAmBpB,qBAAa,2BAA2B;IACtC,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,eAAe,CAAiB;gBAE5B,WAAW,EAAE,2BAA2B;IAK7C,4BAA4B,QAAa,OAAO,CAAC,IAAI,CAAC,CAM3D;IAEF,OAAO,CAAC,8BAA8B,CAUpC;IAEF,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,iCAAiC,CAEvC;IAEF,OAAO,CAAC,4BAA4B,CAclC;IAEF,OAAO,CAAC,qBAAqB,CAM3B;IAEF,OAAO,CAAC,mBAAmB,CAKzB;IAEF,OAAO,CAAC,kCAAkC,CAqCxC;IAEF,OAAO,CAAC,mCAAmC,CAEzC;CACH"}
|
package/dist/esm/initialize.js
CHANGED
|
@@ -51,14 +51,14 @@ export class PlaywrightServiceInitialize {
|
|
|
51
51
|
process.exit(0);
|
|
52
52
|
};
|
|
53
53
|
isServiceConfigFileAlreadyPresent = () => {
|
|
54
|
-
return fs.existsSync(this.
|
|
54
|
+
return fs.existsSync(this.createAzurePlaywrightConfigFileName());
|
|
55
55
|
};
|
|
56
56
|
displayAdditionalInformation = () => {
|
|
57
|
-
const runCommandParallelWorkers = this._packageManager.runCommand("playwright", `test -c ${this.
|
|
58
|
-
console.log(`\n\nTo run playwrights tests using Playwright
|
|
57
|
+
const runCommandParallelWorkers = this._packageManager.runCommand("playwright", `test -c ${this.createAzurePlaywrightConfigFileName()} --workers=20`);
|
|
58
|
+
console.log(`\n\nTo run playwrights tests using Playwright Workspaces\n`);
|
|
59
59
|
console.log(`\t${runCommandParallelWorkers}\n`);
|
|
60
60
|
console.log("Getting Started - https://aka.ms/pww/docs/quickstart\n");
|
|
61
|
-
console.log("If you're already using the
|
|
61
|
+
console.log("If you're already using the Playwright Workspaces, please review the quickstart guide [https://aka.ms/pww/docs/quickstart] to ensure your tests continue running smoothly.");
|
|
62
62
|
};
|
|
63
63
|
installServicePackage = async () => {
|
|
64
64
|
const command = this._packageManager.installDevDependencyCommand("@azure/playwright @azure/identity");
|
|
@@ -66,20 +66,20 @@ export class PlaywrightServiceInitialize {
|
|
|
66
66
|
await executeCommand(command);
|
|
67
67
|
};
|
|
68
68
|
createServiceConfig = async () => {
|
|
69
|
-
const serviceConfigFile = this.
|
|
70
|
-
const serviceConfigFileContent = this.
|
|
69
|
+
const serviceConfigFile = this.createAzurePlaywrightConfigFileName();
|
|
70
|
+
const serviceConfigFileContent = this.createAzurePlaywrightConfigContent();
|
|
71
71
|
await fs.promises.writeFile(serviceConfigFile, serviceConfigFileContent);
|
|
72
72
|
console.log(`Success! Created service configuration file - ${serviceConfigFile}`);
|
|
73
73
|
};
|
|
74
|
-
|
|
74
|
+
createAzurePlaywrightConfigContent = () => {
|
|
75
75
|
const customerConfigFileName = getFileReferenceForImport(this._setupConfig.playwrightConfigFile);
|
|
76
76
|
const importCommandTypeScript = `import { defineConfig } from '@playwright/test';
|
|
77
|
-
import {
|
|
77
|
+
import { createAzurePlaywrightConfig, ServiceOS } from '@azure/playwright';
|
|
78
78
|
import { DefaultAzureCredential } from '@azure/identity';
|
|
79
79
|
import config from '${customerConfigFileName}';
|
|
80
80
|
`;
|
|
81
81
|
const importCommandJavaScript = `const { defineConfig } = require('@playwright/test');
|
|
82
|
-
const {
|
|
82
|
+
const { createAzurePlaywrightConfig, ServiceOS } = require('@azure/playwright');
|
|
83
83
|
const { DefaultAzureCredential } = require('@azure/identity');
|
|
84
84
|
const config = require('${customerConfigFileName}');
|
|
85
85
|
`;
|
|
@@ -91,9 +91,9 @@ const config = require('${customerConfigFileName}');
|
|
|
91
91
|
/* Learn more about service configuration at https://aka.ms/pww/docs/config */
|
|
92
92
|
export default defineConfig(
|
|
93
93
|
config,
|
|
94
|
-
|
|
94
|
+
createAzurePlaywrightConfig(config, {
|
|
95
95
|
exposeNetwork: '<loopback>',
|
|
96
|
-
|
|
96
|
+
connectTimeout: 3 * 60 * 1000, // 3 minutes
|
|
97
97
|
os: ServiceOS.LINUX,
|
|
98
98
|
credential: new DefaultAzureCredential(),
|
|
99
99
|
})
|
|
@@ -101,7 +101,7 @@ export default defineConfig(
|
|
|
101
101
|
`;
|
|
102
102
|
return content;
|
|
103
103
|
};
|
|
104
|
-
|
|
104
|
+
createAzurePlaywrightConfigFileName = () => {
|
|
105
105
|
return "playwright.service.config" + Extensions[this._setupConfig.projectLanguage];
|
|
106
106
|
};
|
|
107
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../src/initialize.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAMjE,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,SAAS,GAAmB;IAChC;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,QAAQ,CAAC,oBAAoB;QACtC,OAAO,EAAE,IAAI;KACd;IACD;QACE,IAAI,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAClD,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,QAAQ,CAAC,6BAA6B;QAC/C,OAAO,EAAE,IAAI;KACd;CACF,CAAC;AAEF,MAAM,OAAO,2BAA2B;IAC9B,YAAY,CAA8B;IAC1C,eAAe,CAAiB;IAExC,YAA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GAAG,CAAC,+BAA+B,OAAO,GAAG,CAAC,CAAC;QACvD,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC;IAEM,mBAAmB,GAAG,KAAK,IAAmB,EAAE;QACtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,mCAAmC,EAAE,CAAC;QACrE,MAAM,wBAAwB,GAAG,IAAI,CAAC,kCAAkC,EAAE,CAAC;QAC3E,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,iBAAiB,EAAE,wBAAwB,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,iDAAiD,iBAAiB,EAAE,CAAC,CAAC;IACpF,CAAC,CAAC;IAEM,kCAAkC,GAAG,GAAW,EAAE;QACxD,MAAM,sBAAsB,GAAG,yBAAyB,CACtD,IAAI,CAAC,YAAY,CAAC,oBAAoB,CACvC,CAAC;QAEF,MAAM,uBAAuB,GAAG;;;sBAGd,sBAAsB;CAC3C,CAAC;QAEE,MAAM,uBAAuB,GAAG;;;0BAGV,sBAAsB;CAC/C,CAAC;QAEE,MAAM,aAAa,GACjB,IAAI,CAAC,YAAY,CAAC,eAAe,KAAK,SAAS,CAAC,UAAU;YACxD,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,uBAAuB,CAAC;QAE9B,MAAM,OAAO,GACX,aAAa;YACb;;;;;;;;;;;CAWL,CAAC;QACE,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEM,mCAAmC,GAAG,GAAW,EAAE;QACzD,OAAO,2BAA2B,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IACrF,CAAC,CAAC;CACH","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PromptObject } from \"prompts\";\nimport prompts from \"prompts\";\nimport fs from \"node:fs\";\nimport { Extensions, Languages, Messages } from \"./constants.js\";\nimport type {\n OverridePromptResponse,\n PackageManager,\n PlaywrightServiceInitConfig,\n} from \"./types.js\";\nimport { executeCommand, getFileReferenceForImport } from \"./utils.js\";\nimport { getPackageManager } from \"./packageManager.js\";\n\nconst questions: PromptObject[] = [\n {\n type: \"confirm\",\n name: \"canOverride\",\n message: Messages.CAN_OVERRIDE_MESSAGE,\n initial: true,\n },\n {\n type: (prev: boolean) => (prev ? null : \"confirm\"),\n name: \"confirmationForExit\",\n message: Messages.CONFIRMATION_FOR_EXIT_MESSAGE,\n initial: true,\n },\n];\n\nexport class PlaywrightServiceInitialize {\n private _setupConfig: PlaywrightServiceInitConfig;\n private _packageManager: PackageManager;\n\n constructor(setupConfig: PlaywrightServiceInitConfig) {\n this._setupConfig = setupConfig;\n this._packageManager = getPackageManager();\n }\n\n public addServiceSupportToTestSuite = async (): Promise<void> => {\n const canProceedWithServiceInitialization = await this.checkIfServiceConfigCanBeAdded(); // if service config already present, ask user for overwrite permission\n if (!canProceedWithServiceInitialization) return;\n await this.installServicePackage(); // install service packages\n await this.createServiceConfig(); // create service config file\n this.displayAdditionalInformation(); // display additional information\n };\n\n private checkIfServiceConfigCanBeAdded = async (): Promise<boolean> => {\n if (!this.isServiceConfigFileAlreadyPresent()) return true;\n const response = (await prompts.prompt(questions, {\n onCancel: this.promptOnCancel,\n })) as OverridePromptResponse;\n if (response.canOverride) return true;\n if (!response.confirmationForExit) return this.checkIfServiceConfigCanBeAdded();\n\n console.log(`\\n${Messages.SETUP_PROCESS_EXIT_MESSAGE}`);\n return false;\n };\n\n private promptOnCancel = (): never => {\n process.exit(0);\n };\n\n private isServiceConfigFileAlreadyPresent = (): boolean => {\n return fs.existsSync(this.createAzurePlaywrightConfigFileName());\n };\n\n private displayAdditionalInformation = (): void => {\n const runCommandParallelWorkers = this._packageManager.runCommand(\n \"playwright\",\n `test -c ${this.createAzurePlaywrightConfigFileName()} --workers=20`,\n );\n\n console.log(`\\n\\nTo run playwrights tests using Playwright Workspaces\\n`);\n console.log(`\\t${runCommandParallelWorkers}\\n`);\n\n console.log(\"Getting Started - https://aka.ms/pww/docs/quickstart\\n\");\n\n console.log(\n \"If you're already using the Playwright Workspaces, please review the quickstart guide [https://aka.ms/pww/docs/quickstart] to ensure your tests continue running smoothly.\",\n );\n };\n\n private installServicePackage = async (): Promise<void> => {\n const command = this._packageManager.installDevDependencyCommand(\n \"@azure/playwright @azure/identity\",\n );\n console.log(`Installing Service package (${command})`);\n await executeCommand(command);\n };\n\n private createServiceConfig = async (): Promise<void> => {\n const serviceConfigFile = this.createAzurePlaywrightConfigFileName();\n const serviceConfigFileContent = this.createAzurePlaywrightConfigContent();\n await fs.promises.writeFile(serviceConfigFile, serviceConfigFileContent);\n console.log(`Success! Created service configuration file - ${serviceConfigFile}`);\n };\n\n private createAzurePlaywrightConfigContent = (): string => {\n const customerConfigFileName = getFileReferenceForImport(\n this._setupConfig.playwrightConfigFile,\n );\n\n const importCommandTypeScript = `import { defineConfig } from '@playwright/test';\nimport { createAzurePlaywrightConfig, ServiceOS } from '@azure/playwright';\nimport { DefaultAzureCredential } from '@azure/identity';\nimport config from '${customerConfigFileName}';\n`;\n\n const importCommandJavaScript = `const { defineConfig } = require('@playwright/test');\nconst { createAzurePlaywrightConfig, ServiceOS } = require('@azure/playwright');\nconst { DefaultAzureCredential } = require('@azure/identity');\nconst config = require('${customerConfigFileName}');\n`;\n\n const importCommand =\n this._setupConfig.projectLanguage === Languages.TypeScript\n ? importCommandTypeScript\n : importCommandJavaScript;\n\n const content =\n importCommand +\n `\n/* Learn more about service configuration at https://aka.ms/pww/docs/config */\nexport default defineConfig(\n config,\n createAzurePlaywrightConfig(config, {\n exposeNetwork: '<loopback>',\n connectTimeout: 3 * 60 * 1000, // 3 minutes\n os: ServiceOS.LINUX,\n credential: new DefaultAzureCredential(),\n })\n);\n`;\n return content;\n };\n\n private createAzurePlaywrightConfigFileName = (): string => {\n return \"playwright.service.config\" + Extensions[this._setupConfig.projectLanguage];\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/create-playwright",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Package to setup @azure/playwright",
|
|
5
5
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/create-playwright/README.md",
|
|
6
6
|
"sdk-type": "client",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"azure",
|
|
10
10
|
"cloud",
|
|
11
11
|
"playwright",
|
|
12
|
-
"playwright
|
|
12
|
+
"playwright workspaces",
|
|
13
13
|
"reporting"
|
|
14
14
|
],
|
|
15
15
|
"author": "Microsoft Corporation",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"eslint": "^9.33.0",
|
|
46
46
|
"typescript": "~5.8.3",
|
|
47
47
|
"vitest": "^3.2.3",
|
|
48
|
-
"@azure-tools/test-utils-vitest": "^
|
|
48
|
+
"@azure-tools/test-utils-vitest": "^2.0.1",
|
|
49
49
|
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
|
50
50
|
"@azure/dev-tool": "^1.0.0"
|
|
51
51
|
},
|
|
@@ -98,8 +98,7 @@
|
|
|
98
98
|
"pack": "pnpm pack 2>&1",
|
|
99
99
|
"test": "npm run test:node && npm run test:browser",
|
|
100
100
|
"test:browser": "echo skipped",
|
|
101
|
-
"test:node": "dev-tool run test:vitest --no-test-proxy",
|
|
102
|
-
"test:node:esm": "dev-tool run test:vitest --esm --no-test-proxy",
|
|
101
|
+
"test:node": "dev-tool run build-test --no-browser-test && dev-tool run test:vitest --no-test-proxy",
|
|
103
102
|
"update-snippets": "dev-tool run update-snippets"
|
|
104
103
|
}
|
|
105
104
|
}
|