diff --git a/packages/playwright-ct-core/index.js b/packages/playwright-ct-core/index.js index 79441336e6..9583273ac2 100644 --- a/packages/playwright-ct-core/index.js +++ b/packages/playwright-ct-core/index.js @@ -16,7 +16,7 @@ const { test: baseTest, expect, devices, defineConfig: originalDefineConfig } = require('playwright/test'); const { fixtures } = require('./lib/mount'); -const { clearCacheCommand, findRelatedTestsCommand } = require('./lib/cliOverrides'); +const { clearCacheCommand, findRelatedTestFilesCommand } = require('./lib/cliOverrides'); const { createPlugin } = require('./lib/vitePlugin'); const defineConfig = (...configs) => { @@ -31,7 +31,7 @@ const defineConfig = (...configs) => { ], cli: { 'clear-cache': clearCacheCommand, - 'find-related-tests': findRelatedTestsCommand, + 'find-related-test-files': findRelatedTestFilesCommand, }, } }; diff --git a/packages/playwright-ct-core/src/cliOverrides.ts b/packages/playwright-ct-core/src/cliOverrides.ts index bc2772164f..3ebcd09cbc 100644 --- a/packages/playwright-ct-core/src/cliOverrides.ts +++ b/packages/playwright-ct-core/src/cliOverrides.ts @@ -29,7 +29,7 @@ export async function clearCacheCommand(config: FullConfig, configDir: string) { await removeFolder(cacheDir); } -export async function findRelatedTestsCommand(files: string[], config: FullConfig, configDir: string, suite: Suite) { +export async function findRelatedTestFilesCommand(files: string[], config: FullConfig, configDir: string, suite: Suite) { await buildBundle(config, configDir, suite); - return { relatedTests: affectedTestFiles(files) }; + return { testFiles: affectedTestFiles(files) }; } diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.ts index 1619b5e776..da2ff431a0 100644 --- a/packages/playwright/src/program.ts +++ b/packages/playwright/src/program.ts @@ -97,8 +97,8 @@ export async function removeFolder(folder: string) { } } -function addFindRelatedTestsCommand(program: Command) { - const command = program.command('find-related-tests [source-files...]'); +function addFindRelatedTestFilesCommand(program: Command) { + const command = program.command('find-related-test-files [source-files...]'); command.description('Returns the list of related tests to the given files'); command.option('-c, --config ', `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`); command.action(async (files, options) => { @@ -108,10 +108,10 @@ function addFindRelatedTestsCommand(program: Command) { return { errors: result.errors }; const resolvedFiles = (files as string[]).map(file => path.resolve(process.cwd(), file)); - const override = (config as any)['@playwright/test']?.['cli']?.['find-related-tests']; + const override = (config as any)['@playwright/test']?.['cli']?.['find-related-test-files']; if (override) return await override(resolvedFiles, config, configDir, result.suite); - return { relatedTests: affectedTestFiles(resolvedFiles) }; + return { testFiles: affectedTestFiles(resolvedFiles) }; }); }); } @@ -348,4 +348,4 @@ addShowReportCommand(program); addListFilesCommand(program); addMergeReportsCommand(program); addClearCacheCommand(program); -addFindRelatedTestsCommand(program); +addFindRelatedTestFilesCommand(program); diff --git a/tests/playwright-test/find-related-tests.spec.ts b/tests/playwright-test/find-related-tests.spec.ts index c70bdcf04f..981395ade1 100644 --- a/tests/playwright-test/find-related-tests.spec.ts +++ b/tests/playwright-test/find-related-tests.spec.ts @@ -43,12 +43,12 @@ test('should list related tests', async ({ runCLICommand }) => { if (value) {} test('', () => {}); `, - }, 'find-related-tests', ['helper.ts']); + }, 'find-related-test-files', ['helper.ts']); expect(result.exitCode).toBe(0); expect(result.stderr).toBeFalsy(); const data = JSON.parse(result.stdout); expect(data).toEqual({ - relatedTests: [ + testFiles: [ expect.stringContaining('a.spec.ts'), expect.stringContaining('b.spec.ts'), ] @@ -77,11 +77,11 @@ test('should list related tests for ct', async ({ runCLICommand }) => { await mount(