Skip to content

Instantly share code, notes, and snippets.

View hserang's full-sized avatar

Haroun Serang hserang

View GitHub Profile
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@hserang
hserang / example_factory
Last active March 6, 2018 01:32
Example fixture factory using rosie and chance.js
'use strict';
var _ = require('lodash');
var Chance = require('chance');
var Factory = require('rosie').Factory;
function getExternalTransaction(chance) {
function getAmount() {
return chance.floating({
//setup
var someError = "oops";
//before
if (someError === "oops") {
//do something
} else if (someError === "ohgodwhy") {
//do something else
} else if (someError === "stopthemadness") {
//and more