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

Failed to detect test runner in "getTestRunner" function (in "src/executors/scan/utils/utils.ts") #113

Open
1 of 2 tasks
ltparis2018 opened this issue Aug 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ltparis2018
Copy link

ltparis2018 commented Aug 9, 2024

If possible, please provide a reproduction repository you discovered this bug in.

Unfortunately, the repository I detected this problem, is not a public one. Therefore, I cannot provide a link to it.

Which area/package is the issue in?

@koliveira15/nx-sonarqube

Description

Connected to my test coverage problem (see issue #112), I detected another issue in connection with vite 5.3.5 and nx v19.5.6 during my cause analysis. As mentioned already in the headline it is located in the src/executors/scan/utils/utils.ts file.
There is a getTestRunner method implemented (starting from line 55) that - in my case - was not able to detect the used test runner vitest at all. The reason was, that the function is checking three alternatives only:

  • if the test executor name contains vite,
  • if the test executor name contains jest or
  • if the test executor name contains run-commands.

None of these cases occurred in my project. I could find out that in my case the name was nx:run-script if I executed the command nx sonar <project_name>.

As a consequence, the test runner was not detected and stayed undefined which then prevented the following tasks using it from working.

Interestingly, the determinePaths function (same file, starting at line 89) later was able to know anyway that the test runner is vite. But this was by accident because in this function the test condition for this test runner is wrong (see line 167). It misses a comparison and is always true.

If applicable, please provide the Nx report

No response

Please provide the exception or error you saw

There was no error written out. The coverage report path was simply not found (always empty) and therefore the sonar scan did not perform a coverage analysis.

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@ltparis2018 ltparis2018 added the bug Something isn't working label Aug 9, 2024
@koliveira15
Copy link
Owner

@ltparis2018 can you show me what your test executor looks like which is using the run-script? Using run-script implies you are using an npm script to test your project. If that is the case, the plugin will not be able to determine the test runner based on a script name since I can't account for all permutations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants