fix(testing): playwright cleanup (#18558)
This commit is contained in:
parent
b3f68fe89e
commit
645535be46
@ -10,16 +10,16 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"project": {
|
"project": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The project to add a Playwright configuration to",
|
"description": "The project to add a Playwright configuration to.",
|
||||||
"$default": { "$source": "projectName" },
|
"$default": { "$source": "projectName" },
|
||||||
"x-priority": "important",
|
"x-priority": "important",
|
||||||
"x-prompt": "What is the name of the project to set up Playwright for?"
|
"x-prompt": "What is the name of the project to set up Playwright for?"
|
||||||
},
|
},
|
||||||
"directory": {
|
"directory": {
|
||||||
"type": "string",
|
"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",
|
"x-priority": "important",
|
||||||
"default": "playwright"
|
"default": "e2e"
|
||||||
},
|
},
|
||||||
"js": {
|
"js": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export async function addE2e(host: Tree, options: NormalizedSchema) {
|
|||||||
>('@nx/playwright', nxVersion);
|
>('@nx/playwright', nxVersion);
|
||||||
addProjectConfiguration(host, options.e2eProjectName, {
|
addProjectConfiguration(host, options.e2eProjectName, {
|
||||||
root: options.e2eProjectRoot,
|
root: options.e2eProjectRoot,
|
||||||
sourceRoot: joinPathFragments(options.e2eProjectRoot, ''),
|
sourceRoot: joinPathFragments(options.e2eProjectRoot, 'src'),
|
||||||
targets: {},
|
targets: {},
|
||||||
implicitDependencies: [options.projectName],
|
implicitDependencies: [options.projectName],
|
||||||
});
|
});
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export function normalizeOptions(
|
|||||||
: joinPathFragments(appsDir, appDirectory);
|
: joinPathFragments(appsDir, appDirectory);
|
||||||
|
|
||||||
const e2eProjectRoot = options.rootProject
|
const e2eProjectRoot = options.rootProject
|
||||||
? '.'
|
? 'e2e'
|
||||||
: joinPathFragments(appsDir, `${appDirectory}-e2e`);
|
: joinPathFragments(appsDir, `${appDirectory}-e2e`);
|
||||||
|
|
||||||
const outputPath = joinPathFragments(
|
const outputPath = joinPathFragments(
|
||||||
|
|||||||
@ -6,14 +6,10 @@ export function updateCypressTsConfig(host: Tree, options: NormalizedSchema) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateJson(
|
updateJson(host, `${options.e2eProjectRoot}/tsconfig.json`, (json) => {
|
||||||
host,
|
return {
|
||||||
`${options.e2eProjectRoot}/${options.e2eProjectName}/tsconfig.json`,
|
...json,
|
||||||
(json) => {
|
exclude: [],
|
||||||
return {
|
};
|
||||||
...json,
|
});
|
||||||
exclude: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,10 @@ export async function playwrightExecutor(
|
|||||||
bodyLines: ['use --skipInstall to skip installation.'],
|
bodyLines: ['use --skipInstall to skip installation.'],
|
||||||
});
|
});
|
||||||
const pmc = getPackageManagerCommand();
|
const pmc = getPackageManagerCommand();
|
||||||
execSync(`${pmc.exec} playwright install`, { cwd: workspaceRoot });
|
execSync(`${pmc.exec} playwright install`, {
|
||||||
|
cwd: workspaceRoot,
|
||||||
|
stdio: 'inherit',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = createArgs(options);
|
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[] = [];
|
const args: string[] = [];
|
||||||
|
|
||||||
for (const key in opts) {
|
for (const key in opts) {
|
||||||
|
if (exclude.includes(key)) continue;
|
||||||
|
|
||||||
const value = opts[key];
|
const value = opts[key];
|
||||||
// NOTE: playwright doesn't accept pascalCase args, only kebab-case
|
// NOTE: playwright doesn't accept pascalCase args, only kebab-case
|
||||||
const arg = names(key).fileName;
|
const arg = names(key).fileName;
|
||||||
|
|||||||
@ -2,6 +2,9 @@ import type { Linter } from '@nx/linter';
|
|||||||
|
|
||||||
export interface ConfigurationGeneratorSchema {
|
export interface ConfigurationGeneratorSchema {
|
||||||
project: string;
|
project: string;
|
||||||
|
/**
|
||||||
|
* this is relative to the projectRoot
|
||||||
|
**/
|
||||||
directory: string;
|
directory: string;
|
||||||
js: boolean; // default is false
|
js: boolean; // default is false
|
||||||
skipFormat: boolean;
|
skipFormat: boolean;
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"project": {
|
"project": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The project to add a Playwright configuration to",
|
"description": "The project to add a Playwright configuration to.",
|
||||||
"$default": {
|
"$default": {
|
||||||
"$source": "projectName"
|
"$source": "projectName"
|
||||||
},
|
},
|
||||||
@ -16,9 +16,9 @@
|
|||||||
},
|
},
|
||||||
"directory": {
|
"directory": {
|
||||||
"type": "string",
|
"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",
|
"x-priority": "important",
|
||||||
"default": "playwright"
|
"default": "e2e"
|
||||||
},
|
},
|
||||||
"js": {
|
"js": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user