View index.js
var Aws = require('aws-sdk');
var sinon = require('sinon');
// Only works for 'createBucket', 'update' and a few others since most API methods are generated dynamically
// upon instantiation. Very counterintuitive, thanks Amazon!
var createBucket = sinon.stub(Aws.S3.prototype, 'createBucket');
createBucket.yields(null, 'Me create bucket');
// For other methods, we can 'assign' the stubs to the proto, already defined function won't be overridden
var listBuckets = Aws.S3.prototype.listBuckets = sinon.stub();
View sequelize.js
where: { projectId: 1 },
include: [
model: this.models.myItemThing,
// Sequelize term indicates "use the through table where `type===foo`"
through: {
where: { type: "foo" },

Sequelize Error: Invalid value [object Object]

Error: Invalid value [object Object]

This happens when you think you are passing an integer or string, and you are actually passing in an object!

Somethign like this will produce the same error.

View sequelize-promise-migration.js
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
// queryInterface methods DO return promises. Either of the following with work
// return queryInterface.addColumn(...)
// .then(() => queryInterface.doSomething(...))
// etc.
View atom.styles.less
// get rid of the yellow js file icon
// yellow means modified with the gh plugins
// change to grayish, not yellow
// add this to atom's style.less file:
.icon[data-name$=".js"]:before {
font-family: Devicons;
color: #828997;
content: "\E64E";
View test.js
// foo-module.js = () => {
return "hello bar";
// my-file.test
const foo = require("./foo-module");
module.exports.myBar = () => {
View testTime.js
// I was testing some functionality that relied on `moment()`.
// I wanted to fake the value of the time Moment uses so I could test return values.
// Here is the method I used. Reference:
const test = require("ava");
const sinon = require("sinon");
const moment = require("moment");
let sandbox;
View promise.js
// Sometimes I have a promise chain that returns out of a promise before
// the the execution is actually completed. Maybe i'm not returning correctly?
// Anyway, might be a common problem for a newb, like me.
// here is a way to add a delay in the promise chain to wait for the previous
// promise to complete. This is NOT best practice, but maybe it can be used as
// a troubleshooting tool.
.then(() => {...})
.then(() => {

TypeError: Cannot read property 'getTableName' of undefined or is not a function

I've had this error on numerous occasions. Here are a few things to look for:

  • Check that the table name that is included in the query is spelled correctly, check that is it defined correctly (for sequelize).
  • If you are running tests and using Mockery, check that Mockery is setup correctly. Try removing Mockery and running the test.
  • Check that if you are trying to stub with Sinon, that Mockery isn't ALSO trying to stub out the same object.
  • Example of stubbing with Sinon instead of Mockery: