kamal951
kamal951

Reputation: 187

Cannot find module 'sonar-request' from 'api.js' when I run npm run test

When I run tests on my Sonarqube plugin, if a class call to the api, it returns an error but when there is no call to the api, it works great. Here is the error:

FAIL  src\main\js\__tests__\Cards-test.js
Test suite failed to run

Cannot find module 'sonar-request' from 'api.js'

  at Resolver.resolveModule (node_modules\jest-resolve\build\index.js:151:17)
  at Object.<anonymous> (src\main\js\api.js:176:81)
  at Object.<anonymous> (src\main\js\components\Cards.js:2:38)

How can I correct this error?

Upvotes: 0

Views: 269

Answers (1)

rollstuhlfahrer
rollstuhlfahrer

Reputation: 4078

From the error message, it looks like api.js is part of your own coding (not a dependency).

You reference a sonar-request module on your computer which, according to your error message, does not exist. Usually, you would need to npm install it. But there is no such module on the registry (at the time of this posting)

Please check your api.js file for the mentioned require statement (you will find it on line 176).

Upvotes: 1

Related Questions