Skip to content

Commit

Permalink
fix(testing): playwright cleanup (#18558)
Browse files Browse the repository at this point in the history
  • Loading branch information
barbados-clemens committed Aug 14, 2023
1 parent b3f68fe commit 645535b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function normalizeOptions(
: joinPathFragments(appsDir, appDirectory);

const e2eProjectRoot = options.rootProject
? '.'
? 'e2e'
: joinPathFragments(appsDir, `${appDirectory}-e2e`);

const outputPath = joinPathFragments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
};
});
}
12 changes: 10 additions & 2 deletions packages/playwright/src/executors/playwright/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions packages/playwright/src/generators/configuration/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/playwright/src/generators/configuration/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand Down

1 comment on commit 645535b

@vercel
Copy link

@vercel vercel bot commented on 645535b Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.