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 / dependency-injection-A.js
Created February 14, 2016 00:02
Dependency injection with Suman
const assert = require('assert');
const suman = require('suman');
const Test = suman.init(module,'suman.conf.js'); //we now utilize a suman config file which is useful for configuring reporting, IoC, etc
Test.describe('SecondExample', ['delay', 'db', 'val'], function(delay, db, val){ // normally we only need to inject a couple of values per test
var results = [];
@ORESoftware
ORESoftware / dependency-injection-B.js
Created February 14, 2016 00:18
Dependency injection with Suman
const assert = require('assert');
const suman = require('suman');
const Test = suman.init(module,'suman.conf.js'); //we now utilize a suman config file which is useful for configuring reporting, IoC, etc
Test.describe('SecondExample', function(db, server, request){ // normally we only need to inject a couple of values per test, and we don't really need the dependency array
assert(server.isListening); // values are injected asynchronously, so we are already ready to go
assert(db.isConnected); // values are injected asynchronously, so we are already ready to go
@ORESoftware
ORESoftware / suman.ioc.js
Last active February 14, 2016 01:18
Dependency injection for Suman example
//use your own version of this file at the root of your project to configure dependency injection
module.exports = (suman) => { //load async deps for any of your suman tests
suman.configure({
'request': function () {
@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 / 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')
};