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

Problem with enforcing reportName as function #14

Closed
IanMoroney opened this issue Jun 4, 2019 · 4 comments
Closed

Problem with enforcing reportName as function #14

IanMoroney opened this issue Jun 4, 2019 · 4 comments

Comments

@IanMoroney
Copy link

IanMoroney commented Jun 4, 2019

I have found that SonarQube.testExecution.reportPath does not accept wildcards, so i can't set SonarQube.testExecution.reportPath to './reports/*.xml' as I get this error:

"ERROR: Error during SonarQube Scanner execution ERROR: Error during parsing of generic test execution report '/reports/*.xml'. Look at the SonarQube documentation to know the expected XML format. ERROR: Caused by: /reports/*.xml (No such file or directory)

So, instead I attempted to specify 'reportName' not as a function, but as a filename:

sonarqubeReporter: {
basePath: './', // test files folder
filePattern: '**/*spec.ts', // test files glob pattern
encoding: 'utf-8', // test files encoding
outputFolder: './reports', // report destination
legacyMode: false, // report for Sonarqube < 6.2 (disabled)
reportName: 'headlesschrome.xml'
},

After which, the run fails with:

04 06 2019 15:00:16.787:ERROR [karma-server]: TypeError: reportName is not a function
at sonarqubeReporter.specSuccess (/node_modules/karma-sonarqube-reporter/index.js:55:7)
at sonarqubeReporter.onSpecComplete (/node_modules/karma-sonarqube-reporter/index.js:43:12)
at Server. (/node_modules/karma/lib/events.js:40:26)
at emitTwo (events.js:131:20)
at Server.emit (events.js:214:7)

If I can't determine the name of the report statically (as the current name of the file is: headlesschrome.74.0.3729.linux.0.0.0.xml), and I can't report the filename dynamically, how am I meant to work around this?

@fadc80
Copy link
Owner

fadc80 commented Jun 4, 2019

The current implementation doesn't accept defining the reportName option as a string, but you use a callback function to return whatever you want:

sonarqubeReporter: {
  reportName: (metadata) => {
     return 'headlesschrome.xml';
  }
}

Does it look good to you?

@IanMoroney
Copy link
Author

will test and let you know, thank you

@fadc80
Copy link
Owner

fadc80 commented Jun 4, 2019

As karma allows you to run your tests in multiple browsers, I thought defining the report name dinamically would be a good idea. It was just after I had published the first version that I noticed this wildcard problem.

At that time, as there were already some projects using this npm package, I decided to keep the callback function to avoid a breaking change.

Actually, it would be easy to change the code to accept both: dynamic (callback function) and static (a file name) reportName options. But, I'm kind of busy. Therefore, I think you could use the solution I suggested above or provide such improvement via PR.

@IanMoroney
Copy link
Author

The current implementation doesn't accept defining the reportName option as a string, but you use a callback function to return whatever you want:

sonarqubeReporter: {
  reportName: (metadata) => {
     return 'headlesschrome.xml';
  }
}

Does it look good to you?

I can confirm this works.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants