Issue 1:
Great work on connectOverCDP 👍 I am loving the ability to connect to an existing instance rather than launch a new chrome every time.

Context:

Playwright Version: 1.9.1

Operating System: Mac

Node.js version: 12.x

Browser: Chromium

Code Snippet

const { chromium } = require("playwright");

(async () => {
const browser = await chromium.connectOverCDP({
// NOTE: change this with ws URL by launching chrome with CDP
wsEndpoint: `ws://127.0.0.1: 56685/devtools/browser/a5d5af82-e168-4ebb-8b87-199c3e5dc260`,
});
const contexts = browser.contexts();
const browserContext = contexts[0];
const page = await browserContext.newPage();
await page.goto("https://playwright.dev");
})();

Describe the bug

Error log:

[1] app: 2021-02-28T03:57:53.593Z app:debug 1614484673593 -> Chrome Endpoint: ws://127.0.0.1:56685/devtools/browser/a5d5af82-e168-4ebb-8b87-199c3e5dc260
[1] app: 2021-02-28T03:57:53.643Z app:warn 1614484673641 -> Error: Duplicate target 3E6BA14AC5D3C8825FC23623D1B55050
[1] app: at Object.assert (/Users/vikramtiwari/Documents/code/app/packages/node_modules/playwright/lib/utils/utils.js:80:15)
[1] app: at CRBrowser._onAttachedToTarget (/Users/vikramtiwari/Documents/code/app/packages/node_modules/playwright/lib/server/chromium/crBrowser.js:152:17)
[1] app: at CRSession.emit (events.js:315:20)
[1] app: at CRSession.EventEmitter.emit (domain.js:483:12)
[1] app: at /Users/vikramtiwari/Documents/code/app/packages/node_modules/playwright/lib/server/chromium/crConnection.js:157:22
[1] app: at runNextTicks (internal/process/task_queues.js:62:5)
[1] app: at processImmediate (internal/timers.js:429:9) Promise { <rejected> Error: Duplicate target 3E6BA14AC5D3C8825FC23623D1B55050 at Object.assert (/Users/vikramtiwari/Documents/code/app/packages/node_modules/playwright/lib/utils/utils.js:80:15) at CRBrowser._onAttachedToTarget (/Users/vikramtiwari/Documents/code/app/packages/node_modules/playwright/lib/server/chromium/crBrowser.js:152:17) at CRSession.emit (events.js:315:20) at CRSession.EventEmitter.emit (domain.js:483:12) at /Users/vikramtiwari/Documents/code/app/packages/node_modules/playwright/lib/server/chromium/crConnection.js:157:22 at runNextTicks (internal/process/task_queues.js:62:5) at processImmediate (internal/timers.js:429:9) }

First time connection works properly but next time I try to connect to same WS URL, I see this error.

Issue 2:
Context:

Playwright Version: "@playwright/test": "^1.28.1",

Operating System: Mac

Node.js version: 16

Visual Studio Code version: Version: 1.74.1

Playwright for VSCode extension version: v1.0.1

Browser: N/A

Extra: N/A

Code Snippet

function getTestData() {
return [1, 2];
}

// THIS IS THE ONLY ONE PROPERLY DETECTED BY TEST RUNNER AS A TEST THAT CAN BE EXECUTED
test.describe('Quote - Existing Account - Test Quote Prices', () => {
const testCases = [1, 2];
for (const x of testCases) {
test('my test', async () => {
// fake
});
}
});

const testCases = [1, 2];

test.describe('Quote - Existing Account - Test Quote Prices', () => {
for (const x of quoteTestCases) {
test('my test', async () => {
// fake
});
}
});

test.describe('Quote - Existing Account - Test Quote Prices', () => {
for (const x of testCases) {
test('my test', async () => {
// fake
});
}
});

test.describe('Quote - Existing Account - Test Quote Prices', () => {
for (const x of [1, 2]) {
test('my test', async () => {
// fake
});
}
});

Describe the bug

If test case data for parameterized tests are obtained from any variable declared outside the scope of the current scope or are declared inline in the for loop, the tests do not provide the option to be run.