How to write unit test using moch-knex package?

439
July 17, 2017, at 9:52 PM

How to write unit test using moch-knex package? I used to write with sequelize-mock but now all seems different?

//this is my configuration file for moching my db
'use strict';
import {
  Model
} from 'objection';
import Knex from 'knex';
module.exports = function(config) {
  if (config.enableMockDb) {
    var mockDb = require('mock-knex');
    var db = knex({
      client: 'sqlite'
    });
    mockDb.mock(db);
  } else {
    const knexConfig = {
      client: 'oracledb',
      connection: {
        host: config.host,
        user: config.username,
        password: config.password,
        database: config.database
      },
      debug: true
    }
    // Initialize knex.
    const knex = Knex(knexConfig);
    // Bind all Models to a knex instance. If you only have one database in
    // your server this is all you have to do. For multi database systems, see
    // the Model.bindKnex method.
    Model.knex(knex);
    return knex;
  }
};
Rent Charter Buses Company
READ ALSO
FCM error results - refer error to token

FCM error results - refer error to token

when sending push messages through fcm (through nodejs firebase admin sdk), getting this error structure:

335
JSDoc in VS code for documenting function with module's type

JSDoc in VS code for documenting function with module's type

I want to document a function written in another module, which uses httpClientRequest typed parameter

339
Which way to load navbar for user/admin in NodeJS/AngularJS

Which way to load navbar for user/admin in NodeJS/AngularJS

I have a request, Can anyone tell me, how to properly doI want to make two navbars in my project, first is intended for admin, second for user

238
req.flash() not working after req.session.destroy()

req.flash() not working after req.session.destroy()

Based on a condition, I need to destroy user's current session, and redirect him to a login page with a messageI use flash to have a show-once-only message

379