chore(blob): add version to metadata (#24556)
This commit is contained in:
parent
29e63d1deb
commit
f5d069541d
|
|
@ -31,7 +31,10 @@ type BlobReporterOptions = {
|
||||||
outputDir?: string;
|
outputDir?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const currentVersion = 1;
|
||||||
|
|
||||||
export type BlobReportMetadata = {
|
export type BlobReportMetadata = {
|
||||||
|
version: number;
|
||||||
projectSuffix?: string;
|
projectSuffix?: string;
|
||||||
shard?: { total: number, current: number };
|
shard?: { total: number, current: number };
|
||||||
};
|
};
|
||||||
|
|
@ -50,8 +53,9 @@ export class BlobReporter extends TeleReporterEmitter {
|
||||||
|
|
||||||
override onConfigure(config: FullConfig) {
|
override onConfigure(config: FullConfig) {
|
||||||
const metadata: BlobReportMetadata = {
|
const metadata: BlobReportMetadata = {
|
||||||
|
version: currentVersion,
|
||||||
projectSuffix: process.env.PWTEST_BLOB_SUFFIX,
|
projectSuffix: process.env.PWTEST_BLOB_SUFFIX,
|
||||||
shard: config.shard ? config.shard : undefined,
|
shard: config.shard ?? undefined,
|
||||||
};
|
};
|
||||||
this._messages.push({
|
this._messages.push({
|
||||||
method: 'onBlobReportMetadata',
|
method: 'onBlobReportMetadata',
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import url from 'url';
|
||||||
import type { HttpServer } from '../../packages/playwright-core/src/utils';
|
import type { HttpServer } from '../../packages/playwright-core/src/utils';
|
||||||
import { startHtmlReportServer } from '../../packages/playwright-test/lib/reporters/html';
|
import { startHtmlReportServer } from '../../packages/playwright-test/lib/reporters/html';
|
||||||
import { expect as baseExpect, test as baseTest, stripAnsi } from './playwright-test-fixtures';
|
import { expect as baseExpect, test as baseTest, stripAnsi } from './playwright-test-fixtures';
|
||||||
|
import extractZip from '../../packages/playwright-core/bundles/zip/node_modules/extract-zip';
|
||||||
|
|
||||||
const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION;
|
const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION;
|
||||||
const POSITIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? 'ok' : '✓ ';
|
const POSITIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? 'ok' : '✓ ';
|
||||||
|
|
@ -1159,3 +1160,28 @@ test('blob-report should be next to package.json', async ({ runInlineTest }, tes
|
||||||
expect(fs.existsSync(testInfo.outputPath('foo', 'bar', 'blob-report'))).toBe(false);
|
expect(fs.existsSync(testInfo.outputPath('foo', 'bar', 'blob-report'))).toBe(false);
|
||||||
expect(fs.existsSync(testInfo.outputPath('foo', 'bar', 'baz', 'tests', 'blob-report'))).toBe(false);
|
expect(fs.existsSync(testInfo.outputPath('foo', 'bar', 'baz', 'tests', 'blob-report'))).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('blob-report should include version', async ({ runInlineTest }) => {
|
||||||
|
const reportDir = test.info().outputPath('blob-report');
|
||||||
|
const files = {
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = {
|
||||||
|
reporter: [['blob']]
|
||||||
|
};
|
||||||
|
`,
|
||||||
|
'tests/a.test.js': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('test 1', async ({}) => {});
|
||||||
|
`,
|
||||||
|
};
|
||||||
|
await runInlineTest(files);
|
||||||
|
const reportFiles = await fs.promises.readdir(reportDir);
|
||||||
|
expect(reportFiles).toEqual([expect.stringMatching(/report-.*.zip/)]);
|
||||||
|
|
||||||
|
await extractZip(test.info().outputPath('blob-report', reportFiles[0]), { dir: test.info().outputPath('blob-report') });
|
||||||
|
const reportFile = test.info().outputPath('blob-report', reportFiles[0].replace(/\.zip$/, '.jsonl'));
|
||||||
|
const data = await fs.promises.readFile(reportFile, 'utf8');
|
||||||
|
const events = data.split('\n').filter(Boolean).map(line => JSON.parse(line));
|
||||||
|
const metadataEvent = events.find(e => e.method === 'onBlobReportMetadata');
|
||||||
|
expect(metadataEvent.params.version).toBe(1);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue