【发布时间】:2018-03-26 19:18:58
【问题描述】:
我是应该测试的新手。一直使用 Assert,但我正在尝试新选项。
这个简单的测试不起作用,我很想知道为什么。
Profile.js
class Profile {
constructor(profile_name,user_name,email,language) {
this.profile_name = profile_name;
this.user_name = user_name;
this.email = email;
this.language = language;
}
}
module.exports = Profile;
Profile_test.js
let should = require('should');
let Profile = require('../lib/entities/Profile');
describe('Profile', function() {
describe('#constructor', function() {
it('should return a Profile object', function() {
let profile = new Profile('alfa','Alfa da Silva','alfa@beta.com','java');
let valid = { profile_name: 'alfa', user_name: 'Alfa da Silva', email: 'alfa@beta.com', language: 'java'};
profile.should.equal(valid);
});
});
});
但我收到以下错误:
简介 #构造函数 1) 应该返回一个 Profile 对象
0 通过 (62ms) 1 次失败
1) 简介 #构造函数 应该返回一个 Profile 对象:
AssertionError: expected Profile {profile_name: '阿尔法', user_name: '阿尔法达席尔瓦', 电子邮件:'alfa@beta.com', 语言:'java' } 成为对象 { profile_name: '阿尔法', user_name: '阿尔法达席尔瓦', 电子邮件:'alfa@beta.com', 语言:'java' } + 预期 - 实际
at Assertion.fail (node_modules/should/cjs/should.js:275:17) at Assertion.value (node_modules/should/cjs/should.js:356:19) at Context.<anonymous> (test/Profile_test.js:12:19)
这里有什么问题?我错过了什么吗?
【问题讨论】:
标签: javascript should.js assertj