Skip to content

Commit

Permalink
Use root testDir fallback in projects in playwright plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Sep 23, 2024
1 parent 1e64b6c commit d4c5af9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/knip/src/plugins/playwright/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ const toEntryPatterns = (
testMatch: string | RegExp | Array<string | RegExp> | undefined,
cwd: string,
configDir: string,
localConfig: PlaywrightTestConfig
localConfig: PlaywrightTestConfig,
rootConfig: PlaywrightTestConfig
) => {
if (!testMatch) return [];
const dir = relative(cwd, localConfig.testDir ? join(configDir, localConfig.testDir) : configDir);
const testDir = localConfig.testDir ?? rootConfig.testDir;
const dir = relative(cwd, testDir ? join(configDir, testDir) : configDir);
const patterns = [testMatch].flat().filter((p): p is string => typeof p === 'string');
return patterns.map(pattern => toEntryPattern(join(dir, pattern)));
};
Expand All @@ -33,7 +35,7 @@ const builtinReporters = ['dot', 'line', 'list', 'junit', 'html', 'blob', 'json'
export const resolveEntryPaths: ResolveEntryPaths<PlaywrightTestConfig> = async (localConfig, options) => {
const { cwd, configFileDir } = options;
const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
return projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFileDir, config));
return projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFileDir, config, localConfig));
};

export const resolveConfig: ResolveConfig<PlaywrightTestConfig> = async config => {
Expand Down

0 comments on commit d4c5af9

Please sign in to comment.