0

I am trying to implement CI at my project using Jenkins but I have an error at the Hyperledger Composer module that I do not know how to solve. My unit tests are written using Mocha and Chai.

Error:

ReferenceError: require is not defined
at _generator (eval at <anonymous> (eval at compile (node_modules/composer-runtime/lib/scriptcompiler.js:99:33)), <anonymous>:18:23)
at CompiledScriptBundle.execute (node_modules/composer-runtime/lib/compiledscriptbundle.js:53:29)
at Engine._executeTransaction (node_modules/composer-runtime/lib/engine.transactions.js:125:84)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

Does anybody knows how to solve this problem? Or, does anybody recommends another CI software who works better to test our hyperledger composer code?

Thank you in advance!

  • You can't require node modules inside of business network implementations (ie transaction processor implementations) which is what it looks like the error you are receiving is telling you. – david_k Jul 06 '18 at 15:37
  • @david_k I do not require node modules inside of business network implementations, I just do it in the unit tests. The problem is that I can execute "npm test" from my machine terminal, but I can't do it through the Jenkins. – Gerard Duch Jul 09 '18 at 07:23
  • The error message suggests you are trying to load TP functions into the composer runtime and it has a require in it. This isn't going to work as the composer compiler will not understand the require keyword – david_k Jul 09 '18 at 09:32
  • Yes, I understand. But if I execute npm test, everything goes perfect, I do not have any problems. Is Jenkins who throws me this error. – Gerard Duch Jul 09 '18 at 09:44
  • Maybe the runtime is trying to load js files which aren't part of your business network? It would seem odd that this is specific to jenkins itself but more likely the environment setup for jenkins to execute the tests. – david_k Jul 09 '18 at 10:00
  • Yes, I think the problem may be in the environment setup for jenkins as well. I'll keep trying to setup it correctly, thanks ! :) – Gerard Duch Jul 09 '18 at 13:08

1 Answers1

0

Composer builds currently run using Travis CI - see more here https://hyperledger.github.io/composer/latest/business-network/testing and more info here https://github.com/hyperledger/composer/wiki/Builds incl links. Its possible your test error is because you are running into something similar to this ? require is not defined? node.js

Paul O'Mahony
  • 6,740
  • 1
  • 10
  • 15