Add 2 more env variables
This commit is contained in:
parent
5406aa0557
commit
9c30e766f5
|
|
@ -225,6 +225,14 @@ export default defineConfig({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Blob report supports following configuration options and environment variables:
|
||||||
|
|
||||||
|
| Environment Variable Name | Reporter Config Option| Description | Default
|
||||||
|
|---|---|---|---|
|
||||||
|
| `PLAYWRIGHT_BLOB_OUTPUT_DIR` | `outputDir` | Directory to save the output. Existing content is deleted before writing the new report. | `blob-report`
|
||||||
|
| `PLAYWRIGHT_BLOB_OUTPUT_NAME` | `fileName` | File name for the output. | `report-<hash>-<shard_number>.zip`
|
||||||
|
| `PLAYWRIGHT_BLOB_OUTPUT_FILE` | `outputFile` | Full path for the output. If defined, `outputDir` and `fileName` will be overridden | `undefined`
|
||||||
|
|
||||||
### JSON reporter
|
### JSON reporter
|
||||||
|
|
||||||
JSON reporter produces an object with all information about the test run.
|
JSON reporter produces an object with all information about the test run.
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,8 @@ export class BlobReporter extends TeleReporterEmitter {
|
||||||
outputFile = path.resolve(this._options.configDir, this._options.outputFile);
|
outputFile = path.resolve(this._options.configDir, this._options.outputFile);
|
||||||
// Explicit `outputFile` overrides `outputDir` and `fileName` options.
|
// Explicit `outputFile` overrides `outputDir` and `fileName` options.
|
||||||
if (!outputFile) {
|
if (!outputFile) {
|
||||||
const reportName = this._options.fileName || this._defaultReportName(this._config);
|
const reportName = this._options.fileName || process.env[`PLAYWRIGHT_BLOB_OUTPUT_NAME`] || this._defaultReportName(this._config);
|
||||||
const outputDir = resolveReporterOutputPath('blob-report', this._options.configDir, this._options.outputDir);
|
const outputDir = resolveReporterOutputPath('blob-report', this._options.configDir, this._options.outputDir ?? reportOutputDirFromEnv());
|
||||||
if (!process.env.PWTEST_BLOB_DO_NOT_REMOVE)
|
if (!process.env.PWTEST_BLOB_DO_NOT_REMOVE)
|
||||||
await removeFolders([outputDir]);
|
await removeFolders([outputDir]);
|
||||||
outputFile = path.resolve(outputDir, reportName);
|
outputFile = path.resolve(outputDir, reportName);
|
||||||
|
|
@ -150,6 +150,12 @@ export class BlobReporter extends TeleReporterEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reportOutputDirFromEnv(): string | undefined {
|
||||||
|
if (process.env[`PLAYWRIGHT_BLOB_OUTPUT_DIR`])
|
||||||
|
return path.resolve(process.cwd(), process.env[`PLAYWRIGHT_BLOB_OUTPUT_DIR`]);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function reportOutputFileFromEnv(): string | undefined {
|
function reportOutputFileFromEnv(): string | undefined {
|
||||||
if (process.env[`PLAYWRIGHT_BLOB_OUTPUT_FILE`])
|
if (process.env[`PLAYWRIGHT_BLOB_OUTPUT_FILE`])
|
||||||
return path.resolve(process.cwd(), process.env[`PLAYWRIGHT_BLOB_OUTPUT_FILE`]);
|
return path.resolve(process.cwd(), process.env[`PLAYWRIGHT_BLOB_OUTPUT_FILE`]);
|
||||||
|
|
|
||||||
|
|
@ -1198,7 +1198,57 @@ test('support fileName option', async ({ runInlineTest, mergeReports }) => {
|
||||||
expect(reportFiles.sort()).toEqual(['report-one.zip', 'report-two.zip']);
|
expect(reportFiles.sort()).toEqual(['report-one.zip', 'report-two.zip']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('support PLAYWRIGHT_BLOB_OUTPUT_DIR env variable', async ({ runInlineTest, mergeReports }) => {
|
||||||
|
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30091' });
|
||||||
|
const files = {
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = {
|
||||||
|
reporter: [['blob']],
|
||||||
|
projects: [
|
||||||
|
{ name: 'foo' },
|
||||||
|
]
|
||||||
|
};
|
||||||
|
`,
|
||||||
|
'a.test.js': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('math 1 @smoke', async ({}) => {});
|
||||||
|
`,
|
||||||
|
};
|
||||||
|
|
||||||
|
await runInlineTest(files, undefined, { PLAYWRIGHT_BLOB_OUTPUT_DIR: 'my/dir' });
|
||||||
|
|
||||||
|
const reportDir = test.info().outputPath('my', 'dir');
|
||||||
|
const reportFiles = await fs.promises.readdir(reportDir);
|
||||||
|
expect(reportFiles.sort()).toEqual(['report.zip']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('support PLAYWRIGHT_BLOB_OUTPUT_NAME env variable', async ({ runInlineTest, mergeReports }) => {
|
||||||
|
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30091' });
|
||||||
|
const files = {
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = {
|
||||||
|
reporter: [['blob']],
|
||||||
|
projects: [
|
||||||
|
{ name: 'foo' },
|
||||||
|
]
|
||||||
|
};
|
||||||
|
`,
|
||||||
|
'a.test.js': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('math 1 @smoke', async ({}) => {});
|
||||||
|
`,
|
||||||
|
};
|
||||||
|
|
||||||
|
await runInlineTest(files, undefined, { PLAYWRIGHT_BLOB_OUTPUT_NAME: 'report-one.zip' });
|
||||||
|
await runInlineTest(files, undefined, { PLAYWRIGHT_BLOB_OUTPUT_NAME: 'report-two.zip', PWTEST_BLOB_DO_NOT_REMOVE: '1' });
|
||||||
|
|
||||||
|
const reportDir = test.info().outputPath('blob-report');
|
||||||
|
const reportFiles = await fs.promises.readdir(reportDir);
|
||||||
|
expect(reportFiles.sort()).toEqual(['report-one.zip', 'report-two.zip']);
|
||||||
|
});
|
||||||
|
|
||||||
test('support outputFile option', async ({ runInlineTest, mergeReports }) => {
|
test('support outputFile option', async ({ runInlineTest, mergeReports }) => {
|
||||||
|
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30091' });
|
||||||
const files = (fileSuffix: string) => ({
|
const files = (fileSuffix: string) => ({
|
||||||
'playwright.config.ts': `
|
'playwright.config.ts': `
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
@ -1223,6 +1273,7 @@ test('support outputFile option', async ({ runInlineTest, mergeReports }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('support PLAYWRIGHT_BLOB_OUTPUT_FILE environment variable', async ({ runInlineTest, mergeReports }) => {
|
test('support PLAYWRIGHT_BLOB_OUTPUT_FILE environment variable', async ({ runInlineTest, mergeReports }) => {
|
||||||
|
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30091' });
|
||||||
const files = {
|
const files = {
|
||||||
'playwright.config.ts': `
|
'playwright.config.ts': `
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue