this is my message.test.js file.
var expect = require('expect');
var {generateMessage} = require('./message');
describe('generateMessage', () => {
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: priya@priya-pro:~/node-chat-app$ npm test
[email protected] test /home/priya/node-chat-app mocha server/**/*.test.js generateMessage 1) should generate correct message object
0 passing (12ms) 1 failing
1) generateMessage should generate correct message object: TypeError: expect(...).toBeA is not a function at Context.it (server/utils/message.test.js:12:31)
npm ERR! Test failed. See above for more details.
Help me...
The ownership of the expect library has been donated to jest from v21+. Since then some of the method names and their functionality has been changed. The following modification to code will help to overcome issue.
var expect = require('expect');
var {generateMessage} = require('./message');
describe('generateMessage', () => {
it('should generate correct message object', () => {
var from = 'Jen';
var text = 'Some message';
var message = generateMessage(from, text);
expect(typeof message.createdAt).toBe('number');
expect(message).toMatchObject({from, text});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With