Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55b45ae

Browse files
kashish2508Copilot
andauthored
Fix(playwright): fix ESM/CommonJS mismatch causing "exports/require i… (Azure#35927)
…s not defined" by converting samples to ESM and updating configs ### Packages impacted by this PR ### Issues associated with this PR ### Describe the problem that is addressed by this PR ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) --------- Co-authored-by: Copilot <[email protected]>
1 parent 62c901e commit 55b45ae

File tree

23 files changed

+69
-51
lines changed

23 files changed

+69
-51
lines changed

sdk/loadtesting/playwright/samples/v1/javascript/customising-service-parameters/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "customising-service-parameters",
33
"version": "1.0.0",
4+
"type": "module",
45
"main": "index.js",
56
"scripts": {},
67
"keywords": [],

sdk/loadtesting/playwright/samples/v1/javascript/customising-service-parameters/playwright.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
const { defineConfig, devices } = require('@playwright/test');
2+
import { defineConfig, devices } from '@playwright/test';
33

44
/**
55
* Read environment variables from file.
@@ -10,7 +10,7 @@ const { defineConfig, devices } = require('@playwright/test');
1010
/**
1111
* @see https://playwright.dev/docs/test-configuration
1212
*/
13-
module.exports = defineConfig({
13+
export default defineConfig({
1414
testDir: './tests',
1515
/* Run tests in files in parallel */
1616
fullyParallel: true,
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
const { AzureCliCredential } = require("@azure/identity");
2-
const { createAzurePlaywrightConfig, ServiceOS, ServiceAuth } = require("@azure/playwright");
3-
const { defineConfig } = require('@playwright/test');
4-
const config = require("./playwright.config");
1+
import { AzureCliCredential } from "@azure/identity";
2+
import { createAzurePlaywrightConfig, ServiceOS, ServiceAuth } from "@azure/playwright";
3+
import { defineConfig } from '@playwright/test';
4+
import config from "./playwright.config.js";
55

66
const azureCredential = new AzureCliCredential();
7-
87
const serviceAuthType = ServiceAuth.ENTRA_ID;
98
const os = ServiceOS.LINUX;
109

@@ -18,5 +17,7 @@ const playwrightServiceAdditionalOptions = {
1817
runName: "JavaScript V1 - Sample Run", // Run name for the test run
1918
};
2019

21-
22-
export default defineConfig(config, createAzurePlaywrightConfig(config, playwrightServiceAdditionalOptions));
20+
export default defineConfig(
21+
config,
22+
createAzurePlaywrightConfig(config, playwrightServiceAdditionalOptions)
23+
);

sdk/loadtesting/playwright/samples/v1/javascript/customising-service-parameters/tests/sample.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
const { test, expect } = require('@playwright/test');
2+
import { test, expect } from '@playwright/test';
33

44
test('has title', async ({ page }) => {
55
await page.goto('https://playwright.dev/');

sdk/loadtesting/playwright/samples/v1/javascript/manually-connecting-to-browsers/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "using-manual-launch",
33
"version": "1.0.0",
4+
"type": "module",
45
"main": "index.js",
56
"scripts": {},
67
"keywords": [],

sdk/loadtesting/playwright/samples/v1/javascript/manually-connecting-to-browsers/playwright.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
const { defineConfig, devices } = require('@playwright/test');
2+
import { defineConfig, devices } from '@playwright/test';
33

44
/**
55
* Read environment variables from file.
@@ -10,7 +10,7 @@ const { defineConfig, devices } = require('@playwright/test');
1010
/**
1111
* @see https://playwright.dev/docs/test-configuration
1212
*/
13-
module.exports = defineConfig({
13+
export default defineConfig({
1414
testDir: './tests',
1515
/* Run tests in files in parallel */
1616
fullyParallel: true,
@@ -30,8 +30,8 @@ module.exports = defineConfig({
3030
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
3131
trace: 'on-first-retry',
3232
},
33-
globalSetup: require.resolve('./global-setup'),
34-
globalTeardown: require.resolve('./global-teardown'),
33+
globalSetup: './global-setup.js',
34+
globalTeardown: './global-teardown.js',
3535

3636
/* Configure projects for major browsers */
3737
projects: [
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
const { createAzurePlaywrightConfig } = require("@azure/playwright");
2-
const { defineConfig } = require('@playwright/test');
3-
const { DefaultAzureCredential } = require("@azure/identity");
4-
const config = require("./playwright.config");
1+
import { createAzurePlaywrightConfig } from "@azure/playwright";
2+
import { defineConfig } from '@playwright/test';
3+
import { DefaultAzureCredential } from "@azure/identity";
4+
import config from "./playwright.config.js";
55

6-
export default defineConfig(config, createAzurePlaywrightConfig(config, {
7-
credential: new DefaultAzureCredential()
8-
}));
6+
export default defineConfig(
7+
config,
8+
createAzurePlaywrightConfig(config, {
9+
credential: new DefaultAzureCredential()
10+
})
11+
);

sdk/loadtesting/playwright/samples/v1/javascript/manually-connecting-to-browsers/tests/sample.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
const playwright = require("@playwright/test");
2-
const { getConnectOptions, ServiceOS } = require("@azure/playwright");
3-
const { AzureCliCredential } = require("@azure/identity");
1+
import { test, expect } from "@playwright/test";
2+
import { getConnectOptions, ServiceOS } from "@azure/playwright";
3+
import { AzureCliCredential } from "@azure/identity";
44

5-
const { test, expect } = playwright;
65

76
test("has title", async ({ browserName }) => {
87
const { wsEndpoint, options } = await getConnectOptions();

sdk/loadtesting/playwright/samples/v1/javascript/set-default-authentication-mechanism/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "set-default-authentication-mechanism",
33
"version": "1.0.0",
4+
"type": "module",
45
"main": "index.js",
56
"scripts": {},
67
"keywords": [],

sdk/loadtesting/playwright/samples/v1/javascript/set-default-authentication-mechanism/playwright.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
const { defineConfig, devices } = require('@playwright/test');
2+
import { defineConfig, devices } from '@playwright/test';
33

44
/**
55
* Read environment variables from file.
@@ -10,7 +10,7 @@ const { defineConfig, devices } = require('@playwright/test');
1010
/**
1111
* @see https://playwright.dev/docs/test-configuration
1212
*/
13-
module.exports = defineConfig({
13+
export default defineConfig({
1414
testDir: './tests',
1515
/* Run tests in files in parallel */
1616
fullyParallel: true,

0 commit comments

Comments
 (0)