Skip to content

Commit 61164e6

Browse files
committed
cypress: adjust scripts
1 parent d36cbfd commit 61164e6

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

generators/cypress/generator.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { cypressEntityFiles, cypressFiles } from './files.js';
2727

2828
const { ANGULAR } = clientFrameworkTypes;
2929

30+
const WAIT_TIMEOUT = 3 * 60000;
31+
3032
export default class CypressGenerator extends BaseApplicationGenerator {
3133
async beforeQueue() {
3234
if (!this.fromBlueprint) {
@@ -188,22 +190,28 @@ export default class CypressGenerator extends BaseApplicationGenerator {
188190
},
189191

190192
configure({ application }) {
193+
const { devServerPort, devServerPortProxy: devServerPortE2e = devServerPort } = application;
194+
191195
const clientPackageJson = this.createStorage(this.destinationPath(application.clientRootDir!, 'package.json'));
192196
clientPackageJson.merge({
193197
devDependencies: {
194198
'eslint-plugin-cypress': application.nodeDependencies['eslint-plugin-cypress'],
195199
},
196200
scripts: {
201+
'ci:e2e:run': 'concurrently -k -s first -n application,e2e -c red,blue npm:ci:e2e:server:start npm:e2e:headless',
202+
'ci:e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue npm:app:start npm:e2e:headless`,
203+
cypress: 'cypress open --e2e',
197204
e2e: 'npm run e2e:cypress:headed --',
198-
'e2e:headless': 'npm run e2e:cypress --',
199-
'e2e:cypress:headed': 'npm run e2e:cypress -- --headed',
200205
'e2e:cypress': 'cypress run --e2e --browser chrome',
206+
'e2e:cypress:headed': 'npm run e2e:cypress -- --headed',
201207
'e2e:cypress:record': 'npm run e2e:cypress -- --record',
202-
cypress: 'cypress open --e2e',
208+
'e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue npm:app:start npm:e2e`,
209+
'e2e:devserver': `concurrently -k -s first -n backend,frontend,e2e -c red,yellow,blue npm:backend:start npm:start "wait-on -t ${WAIT_TIMEOUT} http-get://127.0.0.1:${devServerPortE2e} && npm run e2e:headless -- -c baseUrl=http://localhost:${devServerPortE2e}"`,
210+
'pree2e:headless': 'npm run ci:server:await',
211+
'e2e:headless': 'npm run e2e:cypress --',
203212
},
204213
});
205214
},
206-
207215
configureAudits({ application }) {
208216
if (!application.cypressAudit) return;
209217
const clientPackageJson = this.createStorage(this.destinationPath(application.clientRootDir!, 'package.json'));
@@ -220,7 +228,7 @@ export default class CypressGenerator extends BaseApplicationGenerator {
220228
});
221229
},
222230
configureCoverage({ application, source }) {
223-
const { cypressCoverage, clientFrameworkAngular, dasherizedBaseName } = application;
231+
const { cypressCoverage, clientFrameworkAngular, clientRootDir, dasherizedBaseName } = application;
224232
if (!cypressCoverage) return;
225233
const clientPackageJson = this.createStorage(this.destinationPath(application.clientRootDir!, 'package.json'));
226234
clientPackageJson.merge({
@@ -241,7 +249,10 @@ export default class CypressGenerator extends BaseApplicationGenerator {
241249
});
242250
if (clientFrameworkAngular) {
243251
// Add 'ng build --configuration instrumenter' support
244-
this.createStorage('angular.json').setPath(`projects.${dasherizedBaseName}.architect.build.configurations.instrumenter`, {});
252+
this.createStorage(`${clientRootDir}angular.json`).setPath(
253+
`projects.${dasherizedBaseName}.architect.build.configurations.instrumenter`,
254+
{},
255+
);
245256
source.addWebpackConfig?.({
246257
config: `targetOptions.configuration === 'instrumenter'
247258
? {

generators/java/generators/server/generator.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ export default class ServerGenerator extends BaseApplicationGenerator {
9898
});
9999
},
100100
packageJsonE2eScripts({ application }) {
101-
const { devServerPort, devServerPortProxy: devServerPortE2e = devServerPort } = application;
102101
const scriptsStorage = this.packageJson.createStorage('scripts');
103-
const buildCmd = application.buildToolGradle ? 'gradlew' : 'mvnw -ntp';
104102

105103
let applicationWaitTimeout = WAIT_TIMEOUT * (application.applicationTypeGateway ? 2 : 1);
106104
applicationWaitTimeout = application.authenticationTypeOauth2 ? applicationWaitTimeout * 2 : applicationWaitTimeout;
@@ -110,17 +108,6 @@ export default class ServerGenerator extends BaseApplicationGenerator {
110108
scriptsStorage.set({
111109
'ci:server:await': `echo "Waiting for server at port $npm_package_config_backend_port to start" && wait-on -t ${applicationWaitTimeout} ${applicationEndpoint} && echo "Server at port $npm_package_config_backend_port started"`,
112110
});
113-
114-
// TODO add e2eTests property to application.
115-
if (this.jhipsterConfig.testFrameworks?.includes('cypress')) {
116-
scriptsStorage.set({
117-
'pree2e:headless': 'npm run ci:server:await',
118-
'ci:e2e:run': 'concurrently -k -s first -n application,e2e -c red,blue npm:ci:e2e:server:start npm:e2e:headless',
119-
'ci:e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue "./${buildCmd}" npm:e2e:headless`,
120-
'e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue "./${buildCmd}" npm:e2e`,
121-
'e2e:devserver': `concurrently -k -s first -n backend,frontend,e2e -c red,yellow,blue npm:backend:start npm:start "wait-on -t ${WAIT_TIMEOUT} http-get://127.0.0.1:${devServerPortE2e} && npm run e2e:headless -- -c baseUrl=http://localhost:${devServerPortE2e}"`,
122-
});
123-
}
124111
},
125112
});
126113
}

0 commit comments

Comments
 (0)