diff --git a/packages/cli/src/commands/debug/parse-project.ts b/packages/cli/src/commands/debug/parse-project.ts index d0c554947..6ee8a1e2a 100644 --- a/packages/cli/src/commands/debug/parse-project.ts +++ b/packages/cli/src/commands/debug/parse-project.ts @@ -107,9 +107,9 @@ export default class ParseProjectCommand extends Command { checklyConfigConstructs, playwrightConfigPath: checklyConfig.checks?.playwrightConfigPath, include: includeFlag.length ? includeFlag : checklyConfig.checks?.include, - includeFlagProvided: includeFlag.length > 0, playwrightChecks: checklyConfig.checks?.playwrightChecks, - currentCommand: emulatePwTest ? 'pw-test' : undefined, + loadPlaywrightChecksOnly: emulatePwTest, + warnOnWebServerConfig: emulatePwTest && !(includeFlag.length > 0), }) const diagnostics = new Diagnostics() diff --git a/packages/cli/src/commands/pw-test.ts b/packages/cli/src/commands/pw-test.ts index 259e4fb42..e7724330e 100644 --- a/packages/cli/src/commands/pw-test.ts +++ b/packages/cli/src/commands/pw-test.ts @@ -195,9 +195,9 @@ export default class PwTestCommand extends AuthCommand { checklyConfigConstructs, playwrightConfigPath, include: includeFlag.length ? includeFlag : checklyConfig.checks?.include, - includeFlagProvided: includeFlag.length > 0, playwrightChecks: [playwrightCheck], - currentCommand: 'pw-test', + loadPlaywrightChecksOnly: true, + warnOnWebServerConfig: !(includeFlag.length > 0), checkFilter: check => { // Skip non Playwright checks if (!(check instanceof PlaywrightCheck)) { diff --git a/packages/cli/src/constructs/__tests__/fixtures/playwright-check/test-cases/test-webServer/checkly.config.ts b/packages/cli/src/constructs/__tests__/fixtures/playwright-check/test-cases/test-webServer/checkly.config.ts index bae253372..8abf471e6 100644 --- a/packages/cli/src/constructs/__tests__/fixtures/playwright-check/test-cases/test-webServer/checkly.config.ts +++ b/packages/cli/src/constructs/__tests__/fixtures/playwright-check/test-cases/test-webServer/checkly.config.ts @@ -5,6 +5,7 @@ const config = defineConfig({ logicalId: 'playwright-check-fixture', checks: { checkMatch: '**/*.check.ts', + playwrightConfigPath: './playwright.config.ts', }, }) diff --git a/packages/cli/src/constructs/playwright-check.ts b/packages/cli/src/constructs/playwright-check.ts index b32c416f9..734fd3790 100644 --- a/packages/cli/src/constructs/playwright-check.ts +++ b/packages/cli/src/constructs/playwright-check.ts @@ -283,8 +283,7 @@ export class PlaywrightCheck extends RuntimeCheck { } protected async validateWebServerConfig (diagnostics: Diagnostics): Promise { - // Only show webServer warning for pw-test command when --include is not provided - if (Session.currentCommand !== 'pw-test' || Session.includeFlagProvided) { + if (!Session.warnOnWebServerConfig) { return } diff --git a/packages/cli/src/constructs/project.ts b/packages/cli/src/constructs/project.ts index 8cf1f8e34..2f8a09144 100644 --- a/packages/cli/src/constructs/project.ts +++ b/packages/cli/src/constructs/project.ts @@ -248,8 +248,7 @@ export class Session { static parsers = new Map() static constructExports: ConstructExport[] = [] static ignoreDirectoriesMatch: string[] = [] - static currentCommand?: 'pw-test' | 'test' | 'deploy' - static includeFlagProvided?: boolean + static warnOnWebServerConfig?: boolean static packageManager: PackageManager = npmPackageManager static workspace: Result = Err(new Error(`Workspace support not initialized`)) @@ -272,6 +271,7 @@ export class Session { this.parsers = new Map() this.constructExports = [] this.ignoreDirectoriesMatch = [] + this.warnOnWebServerConfig = false this.packageManager = npmPackageManager this.workspace = Err(new Error(`Workspace support not initialized`)) this.resetSharedFiles() diff --git a/packages/cli/src/services/project-parser.ts b/packages/cli/src/services/project-parser.ts index 14ce3c474..62ae3c1bb 100644 --- a/packages/cli/src/services/project-parser.ts +++ b/packages/cli/src/services/project-parser.ts @@ -45,9 +45,9 @@ type ProjectParseOpts = { checklyConfigConstructs?: Construct[] playwrightConfigPath?: string include?: string | string[] - includeFlagProvided?: boolean playwrightChecks?: PlaywrightSlimmedProp[] - currentCommand?: 'pw-test' | 'test' | 'deploy' + loadPlaywrightChecksOnly?: boolean + warnOnWebServerConfig?: boolean enableWorkspaces?: boolean } @@ -144,9 +144,9 @@ export async function parseProject (opts: ProjectParseOpts): Promise { checklyConfigConstructs, playwrightConfigPath, include, - includeFlagProvided, playwrightChecks, - currentCommand, + loadPlaywrightChecksOnly, + warnOnWebServerConfig, enableWorkspaces = true, } = opts @@ -166,7 +166,11 @@ export async function parseProject (opts: ProjectParseOpts): Promise { ignoreWorkspaces: !enableWorkspaces, }) - checklyConfigConstructs?.forEach( + const filteredConstructs = loadPlaywrightChecksOnly + ? checklyConfigConstructs?.filter(c => !(c instanceof PlaywrightCheck)) + : checklyConfigConstructs + + filteredConstructs?.forEach( construct => project.addResource(construct.type, construct.logicalId, construct), ) Session.project = project @@ -179,20 +183,20 @@ export async function parseProject (opts: ProjectParseOpts): Promise { Session.defaultRuntimeId = defaultRuntimeId Session.verifyRuntimeDependencies = verifyRuntimeDependencies ?? true Session.ignoreDirectoriesMatch = ignoreDirectoriesMatch - Session.currentCommand = currentCommand - Session.includeFlagProvided = includeFlagProvided + Session.warnOnWebServerConfig = warnOnWebServerConfig Session.packageManager = packageManager Session.workspace = workspace // TODO: Do we really need all of the ** globs, or could we just put node_modules? const ignoreDirectories = ['**/node_modules/**', '**/.git/**', ...ignoreDirectoriesMatch] - await loadAllCheckFiles(directory, checkMatch, ignoreDirectories) - - // Load sequentially because otherwise Session.checkFileAbsolutePath and - // Session.checkFilePath are going to be subject to race conditions. - await loadAllBrowserChecks(directory, browserCheckMatch, ignoreDirectories, project) - await loadAllMultiStepChecks(directory, multiStepCheckMatch, ignoreDirectories, project) + if (!loadPlaywrightChecksOnly) { + await loadAllCheckFiles(directory, checkMatch, ignoreDirectories) + // Load sequentially because otherwise Session.checkFileAbsolutePath and + // Session.checkFilePath are going to be subject to race conditions. + await loadAllBrowserChecks(directory, browserCheckMatch, ignoreDirectories, project) + await loadAllMultiStepChecks(directory, multiStepCheckMatch, ignoreDirectories, project) + } await loadPlaywrightChecks(directory, playwrightChecks, playwrightConfigPath, include) // private-location must be processed after all checks and groups are loaded.