模拟 Sequelize 模型查询

时间:2021-01-21 14:07:11

标签: node.js typescript jestjs sequelize.js sinon

我正在对一个函数进行单元测试,我想模拟或跳过 sequelize 模型查询。

    create = async (req: Request) => {
    const {
        headers: { traceId },
        params: { userId, testTypeId },
        user: loginUser
    } = req;

    const testType = await TestType.findByPk(testTypeId);

我想模拟或跳过 findByPk 函数,因为它是一个数据库调用。

0 个答案:

没有答案