Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(debug): on legacy cli driver mode #485

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ const config: PlaywrightTestConfig<WorkerOptions> = {
{
name: 'legacy',
use: {
overridePlaywrightVersion: 1.42,
overridePlaywrightVersion: 1.43,
showBrowser: false,
}
},
{
name: 'legacy-reuse',
use: {
overridePlaywrightVersion: 1.42,
overridePlaywrightVersion: 1.43,
showBrowser: true,
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/playwrightTestCLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ export class PlaywrightTestCLI {
return;
const testDirs = this._model.enabledProjects().map(p => p.project.testDir);
const escapedLocations = locations.map(escapeRegex);
const args = ['test',
const args: string[] = ['test',
'-c', configFile,
...escapedLocations,
options.headed ? '--headed' : '',
...this._model.enabledProjectsFilter().map(p => `--project=${p}`),
'--repeat-each', '1',
'--retries', '0',
'--timeout', '0',
'--workers', options.workers,
'--workers', String(options.workers),
].filter(Boolean);
if (parametrizedTestTitle)
args.push(`--grep=${escapeRegex(parametrizedTestTitle)}`);
Expand Down
24 changes: 23 additions & 1 deletion tests/debug-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { expect, test, escapedPathSep } from './utils';
import { TestRun } from './mock/vscode';
import { TestRun, DebugSession } from './mock/vscode';

test('should debug all tests', async ({ activate }) => {
const { vscode } = await activate({
Expand Down Expand Up @@ -177,3 +177,25 @@ test('should end test run when stopping the debugging', async ({ activate }, tes

testRun.token.source.cancel();
});

test('should pass all args as string[] when debugging', async ({ activate }) => {
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30829' });
const { vscode, testController } = await activate({
'playwright.config.js': `module.exports = { testDir: 'tests' }`,
'tests/test.spec.ts': `
import { test } from '@playwright/test';
test('pass', () => {});
`,
});

await testController.expandTestItems(/test.spec/);
const testItems = testController.findTestItems(/pass/);

const profile = testController.debugProfile();
const onDidStartDebugSession = new Promise<DebugSession>(resolve => vscode.debug.onDidStartDebugSession(resolve));
const onDidTerminateDebugSession = new Promise(resolve => vscode.debug.onDidTerminateDebugSession(resolve));
profile.run(testItems);
const session = await onDidStartDebugSession;
expect(session.configuration.args.filter(arg => typeof arg !== 'string')).toEqual([]);
await onDidTerminateDebugSession;
});
7 changes: 4 additions & 3 deletions tests/mock/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ type DebugConfiguration = {
};

class Debug {
private _didStartDebugSession = new EventEmitter();
private _didTerminateDebugSession = new EventEmitter();
private _didStartDebugSession = new EventEmitter<DebugSession>();
private _didTerminateDebugSession = new EventEmitter<DebugSession>();
readonly onDidStartDebugSession = this._didStartDebugSession.event;
readonly onDidTerminateDebugSession = this._didTerminateDebugSession.event;
output = '';
Expand Down Expand Up @@ -673,6 +673,7 @@ class Debug {
});
});
this._debuggerProcess.stderr.on('data', data => this.output += data.toString());
this._debuggerProcess.on('exit', () => this._didTerminateDebugSession.fire(session));
return true;
}

Expand Down Expand Up @@ -716,7 +717,7 @@ class Debug {
}
}

class DebugSession {
export class DebugSession {
constructor(
readonly id: string,
readonly type: string,
Expand Down