fix(testServer): pass use options to listFiles command (#34832)

This commit is contained in:
Max Schmitt 2025-02-18 00:33:45 +01:00 committed by GitHub
parent 715123afbe
commit 1af4e367f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 1 deletions

View File

@ -52,6 +52,7 @@ export type JsonProject = {
testIgnore: JsonPattern[];
testMatch: JsonPattern[];
timeout: number;
use: { [key: string]: any };
};
export type JsonSuite = {
@ -326,7 +327,7 @@ export class TeleReporterReceiver {
dependencies: project.dependencies,
teardown: project.teardown,
snapshotDir: this._absolutePath(project.snapshotDir),
use: {},
use: project.use,
};
}

View File

@ -184,10 +184,17 @@ export class TeleReporterEmitter implements ReporterV2 {
dependencies: project.dependencies,
snapshotDir: this._relativePath(project.snapshotDir),
teardown: project.teardown,
use: this._serializeProjectUseOptions(project.use),
};
return report;
}
private _serializeProjectUseOptions(use: reporterTypes.FullProject['use']): Record<string, any> {
return {
testIdAttribute: use.testIdAttribute,
};
}
private _serializeSuite(suite: reporterTypes.Suite): teleReceiver.JsonSuite {
const result = {
title: suite.title,

View File

@ -120,6 +120,31 @@ test('file watching', async ({ startTestServer, writeFiles }, testInfo) => {
]);
});
test('should list tests with testIdAttribute', async ({ startTestServer, writeFiles }) => {
await writeFiles({
'a.test.ts': `
import { test } from '@playwright/test';
test('foo', () => {});
`,
'playwright.config.ts': `
module.exports = {
projects: [{
name: 'chromium',
use: {
testIdAttribute: 'testId',
}
}]
};
`,
});
const testServerConnection = await startTestServer();
const events = await testServerConnection.listFiles({});
const onProject = events.report.find(e => e.method === 'onProject').params.project;
expect(onProject.name).toBe('chromium');
expect(onProject.use.testIdAttribute).toBe('testId');
});
test('stdio interception', async ({ startTestServer, writeFiles }) => {
const testServerConnection = await startTestServer();
await testServerConnection.initialize({ interceptStdio: true });