use markdown-first way and inverse deps

This commit is contained in:
vitalets 2025-01-16 11:01:54 +04:00
parent 9cd33a752d
commit 2a7ec73ad0
6 changed files with 34 additions and 6 deletions

View file

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

View file

@ -321,6 +321,22 @@ This path will serve as the base directory for each test file snapshot directory
## property: TestConfig.snapshotPathTemplate = %%-test-config-snapshot-path-template-%% ## property: TestConfig.snapshotPathTemplate = %%-test-config-snapshot-path-template-%%
* since: v1.28 * since: v1.28
## property: TestConfig.populateGitInfo
* since: v1.50
- type: ?<[boolean]>
Whether to populate [`property: TestConfig.metadata`] with Git info.
**Usage**
```js title="playwright.config.ts"
import { defineConfig } from '@playwright/test';
export default defineConfig({
populateGitInfo: !!process.env.CI,
});
```
## property: TestConfig.preserveOutput ## property: TestConfig.preserveOutput
* since: v1.10 * since: v1.10
- type: ?<[PreserveOutput]<"always"|"never"|"failures-only">> - type: ?<[PreserveOutput]<"always"|"never"|"failures-only">>

View file

@ -20,7 +20,6 @@ import os from 'os';
import type { Config, Fixtures, Project, ReporterDescription } from '../../types/test'; import type { Config, Fixtures, Project, ReporterDescription } from '../../types/test';
import type { Location } from '../../types/testReporter'; import type { Location } from '../../types/testReporter';
import type { TestRunnerPluginRegistration } from '../plugins'; import type { TestRunnerPluginRegistration } from '../plugins';
import { gitCommitInfo } from '../plugins/gitCommitInfoPlugin';
import { getPackageJsonPath, mergeObjects } from '../util'; import { getPackageJsonPath, mergeObjects } from '../util';
import type { Matcher } from '../util'; import type { Matcher } from '../util';
import type { ConfigCLIOverrides } from './ipc'; import type { ConfigCLIOverrides } from './ipc';
@ -136,9 +135,6 @@ export class FullConfigInternal {
this.webServers = []; this.webServers = [];
} }
if (this.config.populateGitInfo)
this.plugins.push({ factory: gitCommitInfo });
const projectConfigs = configCLIOverrides.projects || userConfig.projects || [userConfig]; const projectConfigs = configCLIOverrides.projects || userConfig.projects || [userConfig];
this.projects = projectConfigs.map(p => new FullProjectInternal(configDir, userConfig, this, p, this.configCLIOverrides, packageJsonDir)); this.projects = projectConfigs.map(p => new FullProjectInternal(configDir, userConfig, this, p, this.configCLIOverrides, packageJsonDir));
resolveProjectDependencies(this.projects); resolveProjectDependencies(this.projects);

View file

@ -17,9 +17,15 @@
import { createGuid, spawnAsync } from 'playwright-core/lib/utils'; import { createGuid, spawnAsync } from 'playwright-core/lib/utils';
import type { TestRunnerPlugin } from './'; import type { TestRunnerPlugin } from './';
import type { FullConfig } from '../../types/testReporter'; import type { FullConfig } from '../../types/testReporter';
import type { FullConfigInternal } from '../common/config';
const GIT_OPERATIONS_TIMEOUT_MS = 1500; const GIT_OPERATIONS_TIMEOUT_MS = 1500;
export const addGitCommitInfoPlugin = (fullConfig: FullConfigInternal) => {
if (fullConfig.config.populateGitInfo)
fullConfig.plugins.push({ factory: gitCommitInfo });
};
export const gitCommitInfo = (options?: GitCommitInfoPluginOptions): TestRunnerPlugin => { export const gitCommitInfo = (options?: GitCommitInfoPluginOptions): TestRunnerPlugin => {
return { return {
name: 'playwright:git-commit-info', name: 'playwright:git-commit-info',

View file

@ -17,6 +17,7 @@
import type { FullResult, TestError } from '../../types/testReporter'; import type { FullResult, TestError } from '../../types/testReporter';
import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; import { webServerPluginsForConfig } from '../plugins/webServerPlugin';
import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin';
import { collectFilesForProject, filterProjects } from './projectUtils'; import { collectFilesForProject, filterProjects } from './projectUtils';
import { createErrorCollectingReporter, createReporters } from './reporters'; import { createErrorCollectingReporter, createReporters } from './reporters';
import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks } from './tasks'; import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks } from './tasks';
@ -70,6 +71,8 @@ export class Runner {
const config = this._config; const config = this._config;
const listOnly = config.cliListOnly; const listOnly = config.cliListOnly;
addGitCommitInfoPlugin(config);
// Legacy webServer support. // Legacy webServer support.
webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p })); webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));

View file

@ -1294,7 +1294,8 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
outputDir?: string; outputDir?: string;
/** /**
* Whether to populate [metadata](https://playwright.dev/docs/api/class-testconfig#test-config-output-metadata) with Git info. * Whether to populate [testConfig.metadata](https://playwright.dev/docs/api/class-testconfig#test-config-metadata)
* with Git info.
* *
* **Usage** * **Usage**
* *
@ -1814,7 +1815,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
metadata: Metadata; metadata: Metadata;
/** /**
* See [testConfig.populateGitInfo](https://playwright.dev/docs/api/class-testconfig#test-config-populategitinfo). * See [testConfig.populateGitInfo](https://playwright.dev/docs/api/class-testconfig#test-config-populate-git-info).
*/ */
populateGitInfo: boolean; populateGitInfo: boolean;