我该如何设计,以便添加单元/集成测试?

时间:2018-07-03 06:31:04

标签: javascript node.js sequelize.js

如何构造应用程序,以便可以使用诸如sizeof(int *)之类的东西来测试服务和/或模型?

app.js

sinon

customerService.js

const customerService = require('./customer/customerService');

(async () => {
    var results1 = await customerService.get();
    console.log(results1);
})();

customerModel.js

require('dotenv/config');
const Sequelize = require('sequelize');
const sequelize = new Sequelize(process.env.DATABASE, process.env.USER, process.env.PASSWORD, {
    host: process.env.HOST,
    dialect: 'mysql',
    operatorsAliases: false,
    define: {
        timestamps: false,
        freezeTableName: true
    },

    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000
    }

});

const customerModel = require('./customerModel')(sequelize, Sequelize);

exports.get = function () {
    return customerModel.findAll().then(cus => cus[0].customername);
};

0 个答案:

没有答案