koliveira15 / nx-sonarqube

A Nx plugin that scans projects using SonarQube / SonarCloud.
MIT License
51 stars 21 forks source link

"determinePaths" fails if used with nx plugins (nx crystals) #71

Closed jahusa02 closed 8 months ago

jahusa02 commented 9 months ago

With nx Crystals, NX changed the way jest is called. (https://nx.dev/concepts/inferred-tasks)

If you don't have a test target in your project.json but a jest config in the project, nx:run-commands is used as an executor instead of @nx/jest:jest,

e.g.:

{
   outputs: [ '{workspaceRoot}\\coverage\\libs\\shared\\entities' ],
   executor: 'nx:run-commands',
   inputs: [ 'default', '^production' ],
   cache: true,
   options: { cwd: 'libs/shared/entities', command: 'jest' },
   configurations: {}
}

Also the options for the testTarget will be different https://github.com/koliveira15/nx-sonarqube/blob/99a070a9122ba7613fc924d65e3314dc3a89b38f/packages/nx-sonarqube/src/executors/scan/utils/utils.ts#L99

the options are:

{ cwd: 'libs/shared/entities', command: 'jest' }

My workaround is to force @nx/jest:jest as the executor in all projects and to configure it under targetDefaults in nx.json like in NX < 18

This issue won't affect old workspaces but definetly new or old ones opting in for nx plugins to infer tasks