[英]Javascript Mocha not working between 2 files
I am having a problem on using simple test with javascript files and Mocha. 我在对javascript文件和Mocha使用简单测试时遇到问题。
In my directory I have 2 files: test.js cont.js 在我的目录中,我有2个文件:test.js cont.js
The content of cont.js : cont.js的内容:
function testFor5(x){
return x;
}
module.exports.testFor5 = testFor5;
The content of test.js: test.js的内容:
const assert = require('assert');
const rank = require('./cont.js')
describe('test1', function() {
it('it should return the value 5', function(){
assert.equal(rank.testFor5(5)==5);
});
})
When I run moocha test.js in terminal I get the following error: 在终端中运行moocha test.js时,出现以下错误:
1) test1 it should return the value 5: 1)test1应该返回值5:
AssertionError: true == "undefined"
at Context.<anonymous> (test.js:7:12)
I have done many tutorials but none of them seems to be working with multiple files. 我已经完成了许多教程,但是似乎都没有使用多个文件。
Thanks for the help. 谢谢您的帮助。
这就是断言的工作原理,即您将值放在期望值之后,并确保需要上等价。
assert.equal(rank.testFor5(5), 5);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.