问题
I was writing composer test.In my origin codes, the logic.js include request.post which interact with other server. I add var request = require('request') in the beginning to avoid error which is "error 'request' is not defined". in this way, I can translate the package into a .bna file, and work well. But when I try to write some unit test with 'embeded', the error came up with ReferenceError: require is not defined. I add the 'require' package in my package.json file.
回答1:
this is because that 'eslint'
is complaining it doesn't know what to do with request when you run npm test
etc.
We shoud add the comment like
/* global getAssetRegistry getFactory emit request */
follow the example: https://github.com/hyperledger/composer-sample-networks/blob/master/packages/basic-sample-network/lib/sample.js#L15
来源:https://stackoverflow.com/questions/52377517/i-am-using-composer-embeded-to-test-my-code-when-i-add-request-function-to-inte