【发布时间】:2018-06-07 22:47:08
【问题描述】:
我正在尝试使用 sequelize-mock、node 和 postgres 构建单元测试,但是每当我查询我的模拟时,无论我是否在模拟中获得当前数据,我都会得到结果。根据我的查询,sequelize-mock 似乎是automatically generated results。我尝试使用autoQueryFallback 选项,但我得到SequelizeMockEmptyQueryQueueError。
例如:
describe('/GET/:email/exists', () => {
it('it should check if email exists - it should fail', async () => {
const email = 'somemail@mail.com';
try {
const res = await fakeDbUtil.isEmailExistsDb(email);
chai.assert.equal(res, null);
} catch(e) {
console.log(e);
}
});
});
我的模拟数据库中没有给定的电子邮件,所以我希望得到null 结果。但是,我得到的结果包含我的模拟和当前电子邮件(覆盖我的模拟原始电子邮件)。
我不确定我是否做错了什么? 还有其他一些可以与 postgres 和 sequelize 一起使用的好的模拟框架吗?
【问题讨论】:
标签: node.js postgresql unit-testing mocking sequelize.js