jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.56k stars 4.02k forks source link

Error parsing file src/test/javascript/cypress/plugins/index.ts SyntaxError #17105

Closed EnziinSystem closed 2 years ago

EnziinSystem commented 2 years ago

My environment:

Then create an application:

? Which *type* of application would you like to create? Monolithic application (recommended for simple projects)
? What is the base name of your application? book
? Do you want to make it reactive with Spring WebFlux? Yes
? What is your default Java package name? com.enziin.book
? Which *type* of authentication would you like to use? JWT authentication (stateless, with a token)
? Which *type* of database would you like to use? SQL (H2, PostgreSQL, MySQL, MariaDB, MSSQL)
? Which *production* database would you like to use? MySQL
? Which *development* database would you like to use? H2 with disk-based persistence
? Would you like to use Maven or Gradle for building the backend? Maven
? Do you want to use the JHipster Registry to configure, monitor and scale your application? Yes
? Which other technologies would you like to use? Elasticsearch as search engine, API first development using OpenAPI-generator
? Which *Framework* would you like to use for the client? Angular
? Do you want to generate the admin UI? Yes
? Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
? Would you like to enable internationalization support? Yes
? Please choose the native language of the application English
? Please choose additional languages to install Vietnamese
? Besides JUnit and Jest, which testing frameworks would you like to use? Cypress
? Would you like to install other generators from the JHipster Marketplace? No
? Would you like to generate code coverage for Cypress tests? [Experimental] Yes

The error message:

   create .prettierrc
   create .prettierignore
    force .yo-rc-global.json
   create package.json
    force .yo-rc.json
   create .gitattributes
   create .editorconfig
   create .husky/pre-commit
   create .gitignore
   create sonar-project.properties
   create .lintstagedrc.js
   create mvnw
   create mvnw.cmd
   create .mvn/wrapper/maven-wrapper.jar
   create .mvn/wrapper/maven-wrapper.properties
   create npmw
   create npmw.cmd
   create src/main/resources/banner.txt
   create src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml
   create src/main/resources/config/liquibase/master.xml
   create src/main/docker/jib/entrypoint.sh
   create .mvn/wrapper/MavenWrapperDownloader.java
   create checkstyle.xml
   create pom.xml

...

   create cypress.json
   create cypress-audits.json
   create src/test/javascript/cypress/fixtures/integration-test.png
   create src/test/javascript/cypress/.eslintrc.json
   create src/test/javascript/cypress/tsconfig.json
ERROR! Error parsing file src/test/javascript/cypress/plugins/index.ts: SyntaxError: ';' expected. (27:4)
  25 |       return launchOptions
  26 |     }
> 27 |   });
     |    ^
  28 |
  29 |   on('task', {
  30 |     lighthouse: lighthouse((lighthouseReport) => {

At: 1: // ***********************************************************
2: // This example plugins/index.js can be used to load plugins
3: //
4: // You can change the location of this file or turn off loading
5: // the plugins file with the 'pluginsFile' configuration option.
6: //
7: // You can read more here:
8: // https://on.cypress.io/plugins-guide
9: // ***********************************************************
10: 
11: // This function is called when a project is opened or re-opened (e.g. due to
12: // the project's config changing)
13: import fs = require('fs');
14: import { lighthouse, pa11y, prepareAudit } from 'cypress-audit';
15: import ReportGenerator = require('lighthouse/report/generator/report-generator');
16: /**
17:  * @type {Cypress.PluginConfig}
18:  */
19: module.exports = (on, config) => {
20:   // `on` is used to hook into various events Cypress emits
21: // `config` is the resolved Cypress config  on('before:browser:launch', (browser, launchOptions) => {
22:     prepareAudit(launchOptions);
23:     if (browser.name === 'chrome' && browser.isHeadless) {
24:       launchOptions.args.push('--disable-gpu');
25:       return launchOptions
26:     }
27:   });
28: 
29:   on('task', {
30:     lighthouse: lighthouse((lighthouseReport) => {
31:       !fs.existsSync('target/cypress') && fs.mkdirSync('target/cypress', { recursive: true });
32:       fs.writeFileSync('target/cypress/lhreport.html', ReportGenerator.generateReport(lighthouseReport.lhr, 'html'));
33:     }),
34:     pa11y: pa11y(),
35:   });
36:     require('@cypress/code-coverage/task')(on, config);
37:     return config;
38: }
39: 
Error: Error parsing file src/test/javascript/cypress/plugins/index.ts: SyntaxError: ';' expected. (27:4)
  25 |       return launchOptions
  26 |     }
> 27 |   });
     |    ^
  28 |
  29 |   on('task', {
  30 |     lighthouse: lighthouse((lighthouseReport) => {
nomuna commented 2 years ago

I could reproduce the problem on my machine and was able to fix this adding the missing semicolon. :D

Pull request submitted. I have also noticed that a new key named cypressCoverage lands in the .yo-rc.json wich doesn't appear in the jdl grammar... Was able to track it down in the file generator-base.js L2633. Is it going to be added to the jdl some time in the future?


"cypressCoverage": true