removed from full config, set ver 1.51 and handle ui mode

This commit is contained in:
vitalets 2025-01-18 18:43:40 +04:00
parent 7e18ec14f3
commit 7355ed3e45
8 changed files with 43 additions and 17 deletions

View file

@ -64,12 +64,6 @@ See [`property: TestConfig.maxFailures`].
See [`property: TestConfig.metadata`].
## property: FullConfig.populateGitInfo
* since: v1.50
- type: <[boolean]>
See [`property: TestConfig.populateGitInfo`].
## property: FullConfig.preserveOutput
* since: v1.10
- type: <[PreserveOutput]<"always"|"never"|"failures-only">>

View file

@ -322,10 +322,10 @@ This path will serve as the base directory for each test file snapshot directory
* since: v1.28
## property: TestConfig.populateGitInfo
* since: v1.50
* since: v1.51
- type: ?<[boolean]>
Whether to populate [`property: TestConfig.metadata`] with Git info.
Whether to populate [`property: TestConfig.metadata`] with Git info. The metadata will automatically appear in the HTML report and is available in Reporter API.
**Usage**

View file

@ -46,6 +46,7 @@ export class FullConfigInternal {
readonly plugins: TestRunnerPluginRegistration[];
readonly projects: FullProjectInternal[] = [];
readonly singleTSConfigPath?: string;
readonly populateGitInfo: boolean;
cliArgs: string[] = [];
cliGrep: string | undefined;
cliGrepInvert: string | undefined;
@ -75,6 +76,7 @@ export class FullConfigInternal {
const privateConfiguration = (userConfig as any)['@playwright/test'];
this.plugins = (privateConfiguration?.plugins || []).map((p: any) => ({ factory: p }));
this.singleTSConfigPath = pathResolve(configDir, userConfig.tsconfig);
this.populateGitInfo = takeFirst(userConfig.populateGitInfo, false);
this.globalSetups = (Array.isArray(userConfig.globalSetup) ? userConfig.globalSetup : [userConfig.globalSetup]).map(s => resolveScript(s, configDir)).filter(script => script !== undefined);
this.globalTeardowns = (Array.isArray(userConfig.globalTeardown) ? userConfig.globalTeardown : [userConfig.globalTeardown]).map(s => resolveScript(s, configDir)).filter(script => script !== undefined);
@ -91,7 +93,6 @@ export class FullConfigInternal {
grepInvert: takeFirst(userConfig.grepInvert, null),
maxFailures: takeFirst(configCLIOverrides.debug ? 1 : undefined, configCLIOverrides.maxFailures, userConfig.maxFailures, 0),
metadata: takeFirst(userConfig.metadata, {}),
populateGitInfo: takeFirst(userConfig.populateGitInfo, false),
preserveOutput: takeFirst(userConfig.preserveOutput, 'always'),
reporter: takeFirst(configCLIOverrides.reporter, resolveReporters(userConfig.reporter, configDir), [[defaultReporter]]),
reportSlowTests: takeFirst(userConfig.reportSlowTests, { max: 5, threshold: 15000 }),

View file

@ -596,7 +596,6 @@ export const baseFullConfig: reporterTypes.FullConfig = {
grepInvert: null,
maxFailures: 0,
metadata: {},
populateGitInfo: false,
preserveOutput: 'always',
projects: [],
reporter: [[process.env.CI ? 'dot' : 'list']],

View file

@ -22,7 +22,7 @@ import type { FullConfigInternal } from '../common/config';
const GIT_OPERATIONS_TIMEOUT_MS = 1500;
export const addGitCommitInfoPlugin = (fullConfig: FullConfigInternal) => {
if (fullConfig.config.populateGitInfo)
if (fullConfig.populateGitInfo)
fullConfig.plugins.push({ factory: gitCommitInfo });
};

View file

@ -39,6 +39,7 @@ import { baseFullConfig } from '../isomorphic/teleReceiver';
import { InternalReporter } from '../reporters/internalReporter';
import type { ReporterV2 } from '../reporters/reporterV2';
import { internalScreen } from '../reporters/base';
import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin';
const originalStdoutWrite = process.stdout.write;
const originalStderrWrite = process.stderr.write;
@ -406,6 +407,7 @@ export class TestServerDispatcher implements TestServerInterface {
// Preserve plugin instances between setup and build.
if (!this._plugins) {
webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));
addGitCommitInfoPlugin(config);
this._plugins = config.plugins || [];
} else {
config.plugins.splice(0, config.plugins.length, ...this._plugins);

View file

@ -1295,7 +1295,7 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
/**
* Whether to populate [testConfig.metadata](https://playwright.dev/docs/api/class-testconfig#test-config-metadata)
* with Git info.
* with Git info. The metadata will automatically appear in the HTML report and is available in Reporter API.
*
* **Usage**
*
@ -1814,11 +1814,6 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*/
metadata: Metadata;
/**
* See [testConfig.populateGitInfo](https://playwright.dev/docs/api/class-testconfig#test-config-populate-git-info).
*/
populateGitInfo: boolean;
/**
* See [testConfig.preserveOutput](https://playwright.dev/docs/api/class-testconfig#test-config-preserve-output).
*/

View file

@ -0,0 +1,35 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { test } from './ui-mode-fixtures';
test.only('should display git info metadata', async ({ runUITest }) => {
const { page } = await runUITest({
'playwright.config.ts': `
import { defineConfig } from '@playwright/test';
export default defineConfig({
populateGitInfo: true,
});
`,
'a.test.js': `
import { test, expect } from '@playwright/test';
test('should work', async ({}) => {});
`
});
await page.getByTitle('Run all').click();
// todo: what to check?
});