chore: rename find-related-tests to find-related-test-files (#29483)

This commit is contained in:
Pavel Feldman 2024-02-13 15:40:49 -08:00 committed by GitHub
parent 2693614c7a
commit 217c0618df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 13 deletions

View file

@ -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,
},
}
};

View file

@ -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) };
}

View file

@ -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 <file>', `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);

View file

@ -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(<Button />);
});
`,
}, 'find-related-tests', ['helper.tsx'], ctReactCliEntrypoint);
}, 'find-related-test-files', ['helper.tsx'], ctReactCliEntrypoint);
expect(result.exitCode).toBe(0);
const data = JSON.parse(result.stdout);
expect(data).toEqual({
relatedTests: [
testFiles: [
expect.stringContaining('button.spec.tsx'),
]
});