Skip to content

Commit

Permalink
fix(node): add implicit dependency from node e2e project to the app p… (
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo authored Jan 18, 2023
1 parent 93ac55f commit bd3c387
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
35 changes: 19 additions & 16 deletions packages/node/src/generators/e2e-project/e2e-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ export async function e2eProjectGenerator(host: Tree, _options: Schema) {
const options = normalizeOptions(host, _options);
const appProject = readProjectConfiguration(host, options.project);

addProjectConfiguration(host, options.projectName, {
root: options.projectRoot,
addProjectConfiguration(host, options.e2eProjectName, {
root: options.e2eProjectRoot,
implicitDependencies: [options.project],
targets: {
e2e: {
executor: '@nrwl/jest:jest',
outputs: ['{workspaceRoot}/coverage/{projectRoot}'],
outputs: ['{workspaceRoot}/coverage/{e2eProjectRoot}'],
options: {
jestConfig: `${options.projectRoot}/jest.config.ts`,
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
passWithNoTests: true,
},
},
Expand All @@ -43,11 +44,11 @@ export async function e2eProjectGenerator(host: Tree, _options: Schema) {
generateFiles(
host,
path.join(__dirname, 'files/server'),
options.projectRoot,
options.e2eProjectRoot,
{
...options,
...names(options.rootProject ? 'server' : options.project),
offsetFromRoot: offsetFromRoot(options.projectRoot),
offsetFromRoot: offsetFromRoot(options.e2eProjectRoot),
tmpl: '',
}
);
Expand All @@ -56,12 +57,12 @@ export async function e2eProjectGenerator(host: Tree, _options: Schema) {
generateFiles(
host,
path.join(__dirname, 'files/cli'),
options.projectRoot,
options.e2eProjectRoot,
{
...options,
...names(options.rootProject ? 'server' : options.project),
mainFile,
offsetFromRoot: offsetFromRoot(options.projectRoot),
offsetFromRoot: offsetFromRoot(options.e2eProjectRoot),
tmpl: '',
}
);
Expand All @@ -77,11 +78,13 @@ export async function e2eProjectGenerator(host: Tree, _options: Schema) {

if (options.linter === 'eslint') {
const linterTask = await lintProjectGenerator(host, {
project: options.projectName,
project: options.e2eProjectName,
linter: Linter.EsLint,
skipFormat: true,
tsConfigPaths: [joinPathFragments(options.projectRoot, 'tsconfig.json')],
eslintFilePatterns: [`${options.projectRoot}/**/*.{js,ts}`],
tsConfigPaths: [
joinPathFragments(options.e2eProjectRoot, 'tsconfig.json'),
],
eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{js,ts}`],
setParserOptionsProject: false,
skipPackageJson: false,
rootProject: options.rootProject,
Expand All @@ -99,7 +102,7 @@ export async function e2eProjectGenerator(host: Tree, _options: Schema) {
function normalizeOptions(
tree: Tree,
options: Schema
): Omit<Schema, 'name'> & { projectRoot: string; projectName: string } {
): Omit<Schema, 'name'> & { e2eProjectRoot: string; e2eProjectName: string } {
const { layoutDirectory, projectDirectory } = extractLayoutDirectory(
options.directory
);
Expand All @@ -110,16 +113,16 @@ function normalizeOptions(
? `${names(projectDirectory).fileName}/${names(name).fileName}`
: names(name).fileName;

const projectName = appDirectory.replace(new RegExp('/', 'g'), '-');
const e2eProjectName = appDirectory.replace(new RegExp('/', 'g'), '-');

const projectRoot = options.rootProject
const e2eProjectRoot = options.rootProject
? 'e2e'
: joinPathFragments(appsDir, appDirectory);

return {
...options,
projectRoot,
projectName,
e2eProjectRoot,
e2eProjectName,
port: options.port ?? 3000,
rootProject: !!options.rootProject,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */
export default {
displayName: '<%= projectName %>',
displayName: '<%= e2eProjectName %>',
preset: '<%= offsetFromRoot %>/jest.preset.js',
globals: {
'ts-jest': {
Expand All @@ -13,5 +13,5 @@ export default {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '<%= offsetFromRoot %>/coverage/<%= projectName %>',
coverageDirectory: '<%= offsetFromRoot %>/coverage/<%= e2eProjectName %>',
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */
export default {
displayName: '<%= projectName %>',
displayName: '<%= e2eProjectName %>',
preset: '<%= offsetFromRoot %>jest.preset.js',
globals: {
'ts-jest': {
Expand All @@ -15,5 +15,5 @@ export default {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '<%= offsetFromRoot %>coverage/<%= projectName %>',
coverageDirectory: '<%= offsetFromRoot %>coverage/<%= e2eProjectName %>',
};

0 comments on commit bd3c387

Please sign in to comment.