0
votes

I am having a problem on using simple test with javascript files and Mocha.

In my directory I have 2 files: test.js cont.js

The content of cont.js :

function testFor5(x){
return x;
}

module.exports.testFor5 = testFor5;

The content of 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:

1) test1 it should return the value 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.

1

1 Answers

2
votes

This is how assertion works you put your value then the expected value and make sure you require mocha.

assert.equal(rank.testFor5(5), 5);