Skip to content

Instantly share code, notes, and snippets.

View ORESoftware's full-sized avatar
🏐
Focusing

Alexander Mills ORESoftware

🏐
Focusing
View GitHub Profile
@ORESoftware
ORESoftware / ava-bug-example.js
Created February 26, 2016 02:18
This shows that without the use of domains, AVA is not currently able to accurately report which tests fail
/**
* Created by amills001c on 2/25/16.
*/
var test = require('ava');
var fs = require('fs');
///////////////////////////////////////////////////////////
@ORESoftware
ORESoftware / ava-bug-example-part2.js
Last active February 26, 2016 02:34
ava has another bug, shown here, when using domains
// this looks to be a problem
//it will print "one" and "two", followed by "2 passed"
var test = require('ava');
var fs = require('fs');
var domain = require('domain');
var BufferStream = function () {
stream.Transform.apply(this, arguments);
this.sumanReady = false;
this.buffer = [];
};
util.inherits(BufferStream, stream.Transform);
BufferStream.prototype._transform = function (chunk, encoding, done) {
// custom buffering logic
@ORESoftware
ORESoftware / noise.js
Created April 16, 2016 01:01
LOL this sucks...
try {
dir = sumanConfig.servers['*default'].outputDir;
outputPath = path.resolve(dir + '/' + timestamp);
fs.mkdir(outputPath, function (err) {
cb(err, false, outputPath);
});
}
catch (err) {
console.error(err.stack);
cb(err, false);
const suman = require('suman');
const Test = suman.init(module);
Test.describe('FirstExample', function(assert, path, http){ // this is our test suite, and we inject some core modules by name
this.beforeEach('runs before every it()', t => {
const suman = require('suman');
const Test = suman.init(module);
Test.describe('SecondExample', function(db, someval, delay, assert){ // normally we only need to inject a couple of values per test
var results = [];
@ORESoftware
ORESoftware / exampleModule.js
Last active May 10, 2016 02:15
Hot reloading with React + RequireJS
define(['require'],function(require){ // 'require' is a reserved dependency keyword in RequireJS
var module = require('someModule'); //if we know for sure that someModule is already loaded, then we can load it here synchrounously
});
@ORESoftware
ORESoftware / nested.js
Created June 26, 2016 05:38
nested describe blocks
const suman = require('suman');
const Test = suman.init(module);
Test.describe('Test inits', {parallel: false}, function (Pool, assert, path) {
const data = {
size: 5,
filePath: path.resolve(__dirname + '/fixtures/sample-file.js')
};
@ORESoftware
ORESoftware / suman.conf.js
Created December 16, 2016 23:15
suman.conf.js in detail
// => The Suman config file; should always remain at the root of your project
// => If transpile is true, Suman will put your babel deps in ~/.suman/node_modules
// => When you first install Suman, Suman will write a directory called "suman" to your project root,
// it is best practice to simply move the "suman" directory inside your "test" directory,
// when you move the "suman" directory, you must update the "sumanHelpersDir" property below to reflect the path
// from the project root to the "sumanHelpersDir"
// suman.conf.js uses some core utilities, you can change this logic at will
@ORESoftware
ORESoftware / observable-array.js
Created December 18, 2016 21:58
Trying to make an observable array "stay open" so that future values in the array will be seen
const Rx = require('rx-lite');
const values = [1, 2, 3];
const obs = Rx.Observable.from(values);
obs.subscribe(
function onNext(result) {
console.log('item =>', result);