我在学习mocha测试框架和ganache-cli测试环境时,遇到一个小问题
在测试代码中安装视频写如下规则
const assert = require('assert'); const ganache = require('ganache-cli'); //如果变量以大写字母开头,则它就是一个构造函数 const Web3 = require('web3'); //把ganache测试网络的卡插入到web3里面 const web3 = new Web3(ganache.provider()); describe('测试智能合约',()=>{ it('测试web3的版本',()=>{ console.log(web3.version); }); });
然后再Terminal页面输入npm run test
此时报错Cannot find module './build/Release/scrypt'
位置是(F:\MyEclipseWorkspace\Solidity\Inbox\node_modules\scrypt\index.js:3:20)
参考博文https://blog.csdn.net/baidu_25845567/article/details/79952281
将该行代码改为
//var scryptNative = require("./build/Release/scrypt")
var scryptNative = require("scrypt")
再运行输出测试结果