fix(testing): playwright cleanup (#18558)

This commit is contained in:
Caleb Ukle 2023-08-14 11:13:56 -05:00 committed by GitHub
parent b3f68fe89e
commit 645535be46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 20 deletions

View File

@ -10,16 +10,16 @@
"properties": {
"project": {
"type": "string",
"description": "The project to add a Playwright configuration to",
"description": "The project to add a Playwright configuration to.",
"$default": { "$source": "projectName" },
"x-priority": "important",
"x-prompt": "What is the name of the project to set up Playwright for?"
},
"directory": {
"type": "string",
"description": "A directory where the project is placed relative from the project root",
"description": "A directory where the project is placed relative from the project root.",
"x-priority": "important",
"default": "playwright"
"default": "e2e"
},
"js": {
"type": "boolean",

View File

@ -29,7 +29,7 @@ export async function addE2e(host: Tree, options: NormalizedSchema) {
>('@nx/playwright', nxVersion);
addProjectConfiguration(host, options.e2eProjectName, {
root: options.e2eProjectRoot,
sourceRoot: joinPathFragments(options.e2eProjectRoot, ''),
sourceRoot: joinPathFragments(options.e2eProjectRoot, 'src'),
targets: {},
implicitDependencies: [options.projectName],
});

View File

@ -45,7 +45,7 @@ export function normalizeOptions(
: joinPathFragments(appsDir, appDirectory);
const e2eProjectRoot = options.rootProject
? '.'
? 'e2e'
: joinPathFragments(appsDir, `${appDirectory}-e2e`);
const outputPath = joinPathFragments(

View File

@ -6,14 +6,10 @@ export function updateCypressTsConfig(host: Tree, options: NormalizedSchema) {
return;
}
updateJson(
host,
`${options.e2eProjectRoot}/${options.e2eProjectName}/tsconfig.json`,
(json) => {
updateJson(host, `${options.e2eProjectRoot}/tsconfig.json`, (json) => {
return {
...json,
exclude: [],
};
}
);
});
}

View File

@ -76,7 +76,10 @@ export async function playwrightExecutor(
bodyLines: ['use --skipInstall to skip installation.'],
});
const pmc = getPackageManagerCommand();
execSync(`${pmc.exec} playwright install`, { cwd: workspaceRoot });
execSync(`${pmc.exec} playwright install`, {
cwd: workspaceRoot,
stdio: 'inherit',
});
}
const args = createArgs(options);
@ -95,10 +98,15 @@ export async function playwrightExecutor(
});
}
function createArgs(opts: PlaywrightExecutorSchema): string[] {
function createArgs(
opts: PlaywrightExecutorSchema,
exclude: string[] = ['skipInstall']
): string[] {
const args: string[] = [];
for (const key in opts) {
if (exclude.includes(key)) continue;
const value = opts[key];
// NOTE: playwright doesn't accept pascalCase args, only kebab-case
const arg = names(key).fileName;

View File

@ -2,6 +2,9 @@ import type { Linter } from '@nx/linter';
export interface ConfigurationGeneratorSchema {
project: string;
/**
* this is relative to the projectRoot
**/
directory: string;
js: boolean; // default is false
skipFormat: boolean;

View File

@ -7,7 +7,7 @@
"properties": {
"project": {
"type": "string",
"description": "The project to add a Playwright configuration to",
"description": "The project to add a Playwright configuration to.",
"$default": {
"$source": "projectName"
},
@ -16,9 +16,9 @@
},
"directory": {
"type": "string",
"description": "A directory where the project is placed relative from the project root",
"description": "A directory where the project is placed relative from the project root.",
"x-priority": "important",
"default": "playwright"
"default": "e2e"
},
"js": {
"type": "boolean",