与测试框架相关 - 摩卡



我正在使用以太坊平台开发简单的DApp。在这方面,我使用了摩卡测试框架,但出现了此错误。请帮忙...

E:\Tutorials\Blockchain\Practicle\Demo>npm run test

demo@1.0.0 测试 E:\教程\区块链\实践\演示 摩卡

TypeError: Suite argument "title" must be a string. Received type "function"
at createInvalidArgumentTypeError (E:TutorialsBlockchainPracticleDemonode_modulesmochaliberrors.js:158:13)
at new Suite (E:TutorialsBlockchainPracticleDemonode_modulesmochalibsuite.js:45:15)
at Function.Suite.create (E:TutorialsBlockchainPracticleDemonode_modulesmochalibsuite.js:26:17)
at Object.create (E:TutorialsBlockchainPracticleDemonode_modulesmochalibinterfacescommon.js:128:27)
at context.describe.context.context (E:TutorialsBlockchainPracticleDemonode_modulesmochalibinterfacesbdd.js:42:27)
at Object.<anonymous> (E:TutorialsBlockchainPracticleDemotestinbox_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:TutorialsBlockchainPracticleDemonode_modulesmochalibesm-utils.js:20:12)
at Object.exports.loadFilesAsync (E:TutorialsBlockchainPracticleDemonode_modulesmochalibesm-utils.js:33:34)
at Mocha.loadFilesAsync (E:TutorialsBlockchainPracticleDemonode_modulesmochalibmocha.js:421:19)
at singleRun (E:TutorialsBlockchainPracticleDemonode_modulesmochalibclirun-helpers.js:156:15)
at exports.runMocha (E:TutorialsBlockchainPracticleDemonode_modulesmochalibclirun-helpers.js:225:10)
at Object.exports.handler (E:TutorialsBlockchainPracticleDemonode_modulesmochalibclirun.js:366:11)
at E:TutorialsBlockchainPracticleDemonode_modulesmochanode_modulesyargslibcommand.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:UsersPrabhakar'sAppDataRoamingnpm-cache_logs2020-06-21T05_32_41_476Z-debug.log

我得到了答案。我正在发布它,以便它可以对其他人有所帮助......

前面我已经将我的描述方法定义为:

describe(() => {
it("can pass the test", () => {
console.log(accounts);
});

}(; 错误图像

在这里,我已经传递了直接函数,而不是先进行 tittle 这就是为什么摩卡无法成功并返回错误的原因:

套件参数"title"必须是字符串。接收类型"函数">

但是在给出我的合同方法后,它接受它作为一个花絮

describe( 'inbox', () => {
it("can pass the test", () => {
console.log(accounts);
});

}(; 最终图像

最新更新