lundi 21 mars 2016

mocha false negative result

I'm testing a function that generates credentials based on the username and password that are passed in:

generateCredentials(username, password) {
  return {
    username: username,
    password: password
  };
}

Here is my test:

describe('#generateCredentials(username, password)', function() {
    it('creates a JSON object with the passed in arguments', function() {

      var creds = generateCredentials('user', 'pass');

      var expectedCreds =  { username: 'user', password: 'pass' };

      expect(creds).to.equal(expectedCreds);
    });
  });

I get an error:

AssertionError: expected { username: 'user', password: 'pass' } to equal { username: 'user', password: 'pass' }

I don't see any difference in what is expected and what is actually being returned. I console.log creds & expectedCreds and they are identical. Why is mocha throwing an error?

Aucun commentaire:

Enregistrer un commentaire