Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testing): add e2e for root project should not add eslintrc.base #19860

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
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