lundi 18 décembre 2017

Mocha: simple test failing

I'm using Mocha and Expect to run a simple test. The server and client code works, but when I test it, the test fails. Is it a syntax issue, or am I using the wrong variable declarations?


(message.js):

var generateMessage = (from, text) => {
  return {
    from,
    text,
    createdAt: new Date().getTime()
  };
};

module.exports = {generateMessage};


(message.test.js):

var expect = require('expect');

var {generateMessage} = require('./message');

describe('generateMessage', () => { //**HERE**
  it('should generate correct message object', () => {
    var from = 'Jen';
    var text = 'Some message';
    var message = generateMessage(from, text);

    expect(message.createdAt).toBeA('number');
    expect(message).toInclude({from, text});
  });
});


Error: error in console

Aucun commentaire:

Enregistrer un commentaire