Skip to content

Commit

Permalink
fix(testing): add e2e for root project should not add eslintrc.base (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Oct 25, 2023
1 parent 3e0f5c4 commit f5f31ab
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
"default": false,
"description": "Do not add dependencies to `package.json`.",
"x-priority": "internal"
},
"rootProject": {
"description": "Create a application at the root of the workspace",
"type": "boolean",
"default": false,
"hidden": true,
"x-priority": "internal"
}
},
"required": ["project"],
Expand Down
16 changes: 12 additions & 4 deletions e2e/eslint/src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,9 @@ describe('Linter', () => {
// should have plugin extends
expect(appEslint.overrides[0].extends).toBeDefined();
expect(appEslint.overrides[1].extends).toBeDefined();
expect(e2eEslint.overrides[0].extends).toBeDefined();
expect(
e2eEslint.overrides.some((override) => override.extends)
).toBeTruthy();

runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`);
verifySuccessfulMigratedSetup(myapp, mylib);
Expand All @@ -691,7 +693,9 @@ describe('Linter', () => {
// should have no plugin extends
expect(appEslint.overrides[0].extends).toBeUndefined();
expect(appEslint.overrides[1].extends).toBeUndefined();
expect(e2eEslint.overrides[0].extends).toBeUndefined();
expect(
e2eEslint.overrides.some((override) => override.extends)
).toBeFalsy();
});

it('(Angular standalone) should set root project config to app and e2e app and migrate when another lib is added', () => {
Expand All @@ -708,7 +712,9 @@ describe('Linter', () => {

// should have plugin extends
expect(appEslint.overrides[1].extends).toBeDefined();
expect(e2eEslint.overrides[0].extends).toBeDefined();
expect(
e2eEslint.overrides.some((override) => override.extends)
).toBeTruthy();

runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
verifySuccessfulMigratedSetup(myapp, mylib);
Expand All @@ -720,7 +726,9 @@ describe('Linter', () => {
expect(appEslint.overrides[1].extends).toEqual([
'plugin:@nx/angular-template',
]);
expect(e2eEslint.overrides[0].extends).toBeUndefined();
expect(
e2eEslint.overrides.some((override) => override.extends)
).toBeFalsy();
});

it('(Node standalone) should set root project config to app and e2e app and migrate when another lib is added', async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/angular/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
skipPackageJson: options.skipPackageJson,
skipFormat: true,
devServerTarget: `${options.name}:serve:development`,
rootProject: options.rootProject,
});
} else if (options.e2eTestRunner === 'playwright') {
const { configurationGenerator: playwrightConfigurationGenerator } =
Expand All @@ -57,6 +58,7 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
options.name
}`,
webServerAddress: `http://localhost:${options.port ?? 4200}`,
rootProject: options.rootProject,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface CypressE2EConfigSchema {
linter?: Linter;
port?: number | 'cypress-auto';
jsx?: boolean;
rootProject?: boolean;
}

type NormalizedSchema = ReturnType<typeof normalizeOptions>;
Expand Down Expand Up @@ -91,7 +92,7 @@ In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:
return {
...options,
bundler: options.bundler ?? 'webpack',
rootProject: projectConfig.root === '.',
rootProject: options.rootProject ?? projectConfig.root === '.',
linter: options.linter ?? Linter.EsLint,
devServerTarget:
options.devServerTarget ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function configurationGenerator(
js: options.js,
directory: options.directory,
setParserOptionsProject: options.setParserOptionsProject,
rootProject: projectConfig.root === '.',
rootProject: options.rootProject ?? projectConfig.root === '.',
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export interface ConfigurationGeneratorSchema {
* @example: "http://localhost:4200"
**/
webServerAddress?: string;
rootProject?: boolean;
}
7 changes: 7 additions & 0 deletions packages/playwright/src/generators/configuration/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
"default": false,
"description": "Do not add dependencies to `package.json`.",
"x-priority": "internal"
},
"rootProject": {
"description": "Create a application at the root of the workspace",
"type": "boolean",
"default": false,
"hidden": true,
"x-priority": "internal"
}
},
"required": ["project"]
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function addE2e(
skipFormat: true,
devServerTarget: `${options.projectName}:serve`,
jsx: true,
rootProject: options.rootProject,
});
}
case 'playwright': {
Expand All @@ -68,6 +69,7 @@ export async function addE2e(
options.name
}`,
webServerAddress: 'http://localhost:4200',
rootProject: options.rootProject,
});
}
case 'none':
Expand Down

1 comment on commit f5f31ab

@vercel
Copy link

@vercel vercel bot commented on f5f31ab Oct 25, 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-dev-git-master-nrwl.vercel.app
nx.dev
nx-five.vercel.app

Please sign in to comment.