我正在使用Ethereum平台开发简单的DApps。在这方面,我使用了Mocha测试框架,但是出现了这个错误。请帮帮我..。
E:\Tutorials\Blockchain\Practicle\Demo>npm运行测试
demo@1.0.0测试E:\Tutorials\Blockchain\Practicle\Demo mocha
TypeError: Suite argument "title" must be a string. Received type "function"
at createInvalidArgumentTypeError (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\errors.js:158:13)
at new Suite (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\suite.js:45:15)
at Function.Suite.create (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\suite.js:26:17)
at Object.create (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\interfaces\common.js:128:27)
at context.describe.context.context (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\interfaces\bdd.js:42:27)
at Object.<anonymous> (E:\Tutorials\Blockchain\Practicle\Demo\test\inbox_test.js:13:1)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.exports.requireOrImport (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\esm-utils.js:20:12)
at Object.exports.loadFilesAsync (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\esm-utils.js:33:34)
at Mocha.loadFilesAsync (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\mocha.js:421:19)
at singleRun (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\cli\run-helpers.js:156:15)
at exports.runMocha (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\cli\run-helpers.js:225:10)
at Object.exports.handler (E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\lib\cli\run.js:366:11)
at E:\Tutorials\Blockchain\Practicle\Demo\node_modules\mocha\node_modules\yargs\lib\command.js:241:49
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! demo@1.0.0 test: `mocha`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the demo@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Prabhakar's\AppData\Roaming\npm-cache\_logs\2020-06-21T05_32_41_476Z-debug.log发布于 2020-06-22 05:39:08
我得到了答案。我把它贴出来,这样可以帮助别人……
早些时候,我将我的描述方法定义为:
describe(() => {
it("can pass the test", () => {
console.log(accounts);
}););误差图像
在这里,我传递了直接函数,而不是先取tittle,这就是为什么mocha不能成功并错误地返回:
套件参数"title“必须是字符串。接收类型“函数”
但是在给出我的合同方法之后,它接受了它。
describe( 'inbox', () => {
it("can pass the test", () => {
console.log(accounts);
}););最终图像
https://stackoverflow.com/questions/62494968
复制相似问题