fix(testing): playwright cleanup (#18558)
This commit is contained in:
parent
b3f68fe89e
commit
645535be46
@ -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",
|
||||
|
||||
@ -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],
|
||||
});
|
||||
|
||||
@ -45,7 +45,7 @@ export function normalizeOptions(
|
||||
: joinPathFragments(appsDir, appDirectory);
|
||||
|
||||
const e2eProjectRoot = options.rootProject
|
||||
? '.'
|
||||
? 'e2e'
|
||||
: joinPathFragments(appsDir, `${appDirectory}-e2e`);
|
||||
|
||||
const outputPath = joinPathFragments(
|
||||
|
||||
@ -6,14 +6,10 @@ export function updateCypressTsConfig(host: Tree, options: NormalizedSchema) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateJson(
|
||||
host,
|
||||
`${options.e2eProjectRoot}/${options.e2eProjectName}/tsconfig.json`,
|
||||
(json) => {
|
||||
return {
|
||||
...json,
|
||||
exclude: [],
|
||||
};
|
||||
}
|
||||
);
|
||||
updateJson(host, `${options.e2eProjectRoot}/tsconfig.json`, (json) => {
|
||||
return {
|
||||
...json,
|
||||
exclude: [],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user