mocha-retry
Advanced tools
Comparing version 0.0.7 to 0.0.8
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
var Mocha, RetryTest, Suite, interfaces, utils; | ||
var createInterface; | ||
RetryTest = require('./retryTest'); | ||
Mocha = require('mocha'); | ||
interfaces = Mocha.interfaces; | ||
Suite = Mocha.Suite; | ||
utils = Mocha.utils; | ||
require('./retrySuite'); | ||
module.exports = interfaces.bddretry = function(suite) { | ||
var suites; | ||
suites = [suite]; | ||
return suite.on("pre-require", function(context, file, mocha) { | ||
context.before = function(times, name, fn) { | ||
return suites[0].beforeAllWithRetry(times, name, fn); | ||
}; | ||
context.after = function(times, name, fn) { | ||
return suites[0].afterAllWithRetry(times, name, fn); | ||
}; | ||
context.beforeEach = function(times, name, fn) { | ||
return suites[0].beforeEachWithRetry(times, name, fn); | ||
}; | ||
context.afterEach = function(times, name, fn) { | ||
return suites[0].afterEachWithRetry(times, name, fn); | ||
}; | ||
context.describe = context.context = function(times, title, fn) { | ||
var asuite, _ref; | ||
if (fn == null) { | ||
_ref = [times, title], title = _ref[0], fn = _ref[1]; | ||
times = void 0; | ||
} | ||
if ((suites[0].times != null) && (times == null)) { | ||
times = suites[0].times; | ||
} | ||
if ((context.DEFAULT_RETRY != null) && (times == null)) { | ||
times = context.DEFAULT_RETRY; | ||
} | ||
asuite = Suite.create(suites[0], title); | ||
asuite.times = times; | ||
asuite.file = file; | ||
suites.unshift(asuite); | ||
fn.call(asuite); | ||
suites.shift(); | ||
return asuite; | ||
}; | ||
context.xdescribe = context.xcontext = context.describe.skip = function(times, title, fn) { | ||
var asuite, _ref; | ||
if (fn == null) { | ||
_ref = [times, title], title = _ref[0], fn = _ref[1]; | ||
times = void 0; | ||
} | ||
asuite = Suite.create(suites[0], title); | ||
asuite.pending = true; | ||
suites.unshift(asuite); | ||
fn.call(asuite); | ||
return suites.shift(); | ||
}; | ||
context.describe.only = function(times, title, fn) { | ||
var asuite; | ||
asuite = context.describe(times, title, fn); | ||
mocha.grep(asuite.fullTitle()); | ||
return asuite; | ||
}; | ||
context.it = context.itretry = function(times, title, fn) { | ||
var asuite, test, _ref; | ||
asuite = suites[0]; | ||
if ((fn == null) && typeof times !== 'number') { | ||
_ref = [times, title], title = _ref[0], fn = _ref[1]; | ||
times = asuite.times != null ? asuite.times : 1; | ||
} | ||
if (asuite.pending) { | ||
fn = null; | ||
} | ||
test = new RetryTest(times, title, fn); | ||
test.file = file; | ||
asuite.addTest(test); | ||
return test; | ||
}; | ||
context.it.only = function(times, title, fn) { | ||
var reString, test; | ||
test = context.it(times, title, fn); | ||
reString = "^" + utils.escapeRegexp(test.fullTitle()) + "$"; | ||
mocha.grep(new RegExp(reString)); | ||
return test; | ||
}; | ||
return context.xit = context.xspecify = context.it.skip = function(times, title, fn) { | ||
var _ref; | ||
if (title == null) { | ||
return context.it(times); | ||
} | ||
if (fn == null) { | ||
_ref = [1, times, title], times = _ref[0], title = _ref[1], fn = _ref[2]; | ||
} | ||
return context.it(times, title); | ||
}; | ||
}); | ||
module.exports = createInterface = function(Mocha) { | ||
var RetryTest, Suite, interfaces, patchMochaSuite, utils; | ||
RetryTest = require('./retryTest'); | ||
interfaces = Mocha.interfaces; | ||
Suite = Mocha.Suite; | ||
utils = Mocha.utils; | ||
patchMochaSuite = require('./retrySuite'); | ||
patchMochaSuite(Mocha); | ||
return interfaces.bddretry = function(suite) { | ||
var suites; | ||
suites = [suite]; | ||
return suite.on("pre-require", function(context, file, mocha) { | ||
context.before = function(times, name, fn) { | ||
return suites[0].beforeAllWithRetry(times, name, fn); | ||
}; | ||
context.after = function(times, name, fn) { | ||
return suites[0].afterAllWithRetry(times, name, fn); | ||
}; | ||
context.beforeEach = function(times, name, fn) { | ||
return suites[0].beforeEachWithRetry(times, name, fn); | ||
}; | ||
context.afterEach = function(times, name, fn) { | ||
return suites[0].afterEachWithRetry(times, name, fn); | ||
}; | ||
context.describe = context.context = function(times, title, fn) { | ||
var asuite, _ref; | ||
if (fn == null) { | ||
_ref = [times, title], title = _ref[0], fn = _ref[1]; | ||
times = void 0; | ||
} | ||
if ((suites[0].times != null) && (times == null)) { | ||
times = suites[0].times; | ||
} | ||
if ((context.DEFAULT_RETRY != null) && (times == null)) { | ||
times = context.DEFAULT_RETRY; | ||
} | ||
asuite = Suite.create(suites[0], title); | ||
asuite.times = times; | ||
asuite.file = file; | ||
suites.unshift(asuite); | ||
fn.call(asuite); | ||
suites.shift(); | ||
return asuite; | ||
}; | ||
context.xdescribe = context.xcontext = context.describe.skip = function(times, title, fn) { | ||
var asuite, _ref; | ||
if (fn == null) { | ||
_ref = [times, title], title = _ref[0], fn = _ref[1]; | ||
times = void 0; | ||
} | ||
asuite = Suite.create(suites[0], title); | ||
asuite.pending = true; | ||
suites.unshift(asuite); | ||
fn.call(asuite); | ||
return suites.shift(); | ||
}; | ||
context.describe.only = function(times, title, fn) { | ||
var asuite; | ||
asuite = context.describe(times, title, fn); | ||
mocha.grep(asuite.fullTitle()); | ||
return asuite; | ||
}; | ||
context.it = context.itretry = function(times, title, fn) { | ||
var asuite, test, _ref; | ||
asuite = suites[0]; | ||
if ((fn == null) && typeof times !== 'number') { | ||
_ref = [times, title], title = _ref[0], fn = _ref[1]; | ||
times = asuite.times != null ? asuite.times : 1; | ||
} | ||
if (asuite.pending) { | ||
fn = null; | ||
} | ||
test = new RetryTest(times, title, fn); | ||
test.file = file; | ||
asuite.addTest(test); | ||
return test; | ||
}; | ||
context.it.only = function(times, title, fn) { | ||
var reString, test; | ||
test = context.it(times, title, fn); | ||
reString = "^" + utils.escapeRegexp(test.fullTitle()) + "$"; | ||
mocha.grep(new RegExp(reString)); | ||
return test; | ||
}; | ||
return context.xit = context.xspecify = context.it.skip = function(times, title, fn) { | ||
var _ref; | ||
if (title == null) { | ||
return context.it(times); | ||
} | ||
if (fn == null) { | ||
_ref = [1, times, title], times = _ref[0], title = _ref[1], fn = _ref[2]; | ||
} | ||
return context.it(times, title); | ||
}; | ||
}); | ||
}; | ||
}; | ||
}).call(this); |
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
module.exports = require('./bddRetryInterface'); | ||
var Mocha, retryInterface; | ||
Mocha = module.parent.require('mocha'); | ||
retryInterface = require('./bddRetryInterface'); | ||
module.exports = retryInterface(Mocha); | ||
}).call(this); |
{ | ||
"name": "mocha-retry", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "a way to retry tests", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
var Mocha, RetryHook, Suite; | ||
var patchMochaSuite; | ||
Mocha = require('mocha'); | ||
Suite = Mocha.Suite; | ||
RetryHook = require('./retryHook'); | ||
Suite.prototype.beforeAllWithRetry = function(times, title, fn) { | ||
var hook, _ref, _ref1; | ||
if (this.pending) { | ||
return this; | ||
} | ||
if (title == null) { | ||
fn = times; | ||
title = fn.name; | ||
} else if (fn == null) { | ||
if (typeof times === 'number') { | ||
_ref = [void 0, title], title = _ref[0], fn = _ref[1]; | ||
} else { | ||
_ref1 = [times, title], title = _ref1[0], fn = _ref1[1]; | ||
module.exports = patchMochaSuite = function(Mocha) { | ||
var RetryHook, Suite; | ||
Suite = Mocha.Suite; | ||
RetryHook = require('./retryHook'); | ||
Suite.prototype.beforeAllWithRetry = function(times, title, fn) { | ||
var hook, _ref, _ref1; | ||
if (this.pending) { | ||
return this; | ||
} | ||
if (typeof title === 'function') { | ||
fn = title; | ||
if (title == null) { | ||
fn = times; | ||
title = fn.name; | ||
} else if (fn == null) { | ||
if (typeof times === 'number') { | ||
_ref = [void 0, title], title = _ref[0], fn = _ref[1]; | ||
} else { | ||
_ref1 = [times, title], title = _ref1[0], fn = _ref1[1]; | ||
} | ||
if (typeof title === 'function') { | ||
fn = title; | ||
title = fn.name; | ||
} | ||
} | ||
} | ||
title = "\"before all\" hook" + (title ? ": " + title : ""); | ||
hook = new RetryHook(times, title, fn); | ||
hook.parent = this; | ||
hook.timeout(this.timeout()); | ||
hook.slow(this.slow()); | ||
hook.ctx = this.ctx; | ||
this._beforeAll.push(hook); | ||
this.emit("beforeAll", hook); | ||
return this; | ||
}; | ||
Suite.prototype.beforeEachWithRetry = function(times, title, fn) { | ||
var hook, _ref, _ref1; | ||
if (this.pending) { | ||
title = "\"before all\" hook" + (title ? ": " + title : ""); | ||
hook = new RetryHook(times, title, fn); | ||
hook.parent = this; | ||
hook.timeout(this.timeout()); | ||
hook.slow(this.slow()); | ||
hook.ctx = this.ctx; | ||
this._beforeAll.push(hook); | ||
this.emit("beforeAll", hook); | ||
return this; | ||
} | ||
if (title == null) { | ||
fn = times; | ||
title = fn.name; | ||
} else if (fn == null) { | ||
if (typeof times === 'number') { | ||
_ref = [void 0, title], title = _ref[0], fn = _ref[1]; | ||
} else { | ||
_ref1 = [times, title], title = _ref1[0], fn = _ref1[1]; | ||
}; | ||
Suite.prototype.beforeEachWithRetry = function(times, title, fn) { | ||
var hook, _ref, _ref1; | ||
if (this.pending) { | ||
return this; | ||
} | ||
if (typeof title === 'function') { | ||
fn = title; | ||
if (title == null) { | ||
fn = times; | ||
title = fn.name; | ||
} else if (fn == null) { | ||
if (typeof times === 'number') { | ||
_ref = [void 0, title], title = _ref[0], fn = _ref[1]; | ||
} else { | ||
_ref1 = [times, title], title = _ref1[0], fn = _ref1[1]; | ||
} | ||
if (typeof title === 'function') { | ||
fn = title; | ||
title = fn.name; | ||
} | ||
} | ||
} | ||
title = "\"before each\" hook" + (title ? ": " + title : ""); | ||
hook = new RetryHook(times, title, fn); | ||
hook.parent = this; | ||
hook.timeout(this.timeout()); | ||
hook.slow(this.slow()); | ||
hook.ctx = this.ctx; | ||
this._beforeEach.push(hook); | ||
this.emit("beforeEach", hook); | ||
return this; | ||
}; | ||
Suite.prototype.afterAllWithRetry = function(times, title, fn) { | ||
var hook, _ref, _ref1; | ||
if (this.pending) { | ||
title = "\"before each\" hook" + (title ? ": " + title : ""); | ||
hook = new RetryHook(times, title, fn); | ||
hook.parent = this; | ||
hook.timeout(this.timeout()); | ||
hook.slow(this.slow()); | ||
hook.ctx = this.ctx; | ||
this._beforeEach.push(hook); | ||
this.emit("beforeEach", hook); | ||
return this; | ||
} | ||
if (title == null) { | ||
fn = times; | ||
title = fn.name; | ||
} else if (fn == null) { | ||
if (typeof times === 'number') { | ||
_ref = [void 0, title], title = _ref[0], fn = _ref[1]; | ||
} else { | ||
_ref1 = [times, title], title = _ref1[0], fn = _ref1[1]; | ||
}; | ||
Suite.prototype.afterAllWithRetry = function(times, title, fn) { | ||
var hook, _ref, _ref1; | ||
if (this.pending) { | ||
return this; | ||
} | ||
if (typeof title === 'function') { | ||
fn = title; | ||
if (title == null) { | ||
fn = times; | ||
title = fn.name; | ||
} else if (fn == null) { | ||
if (typeof times === 'number') { | ||
_ref = [void 0, title], title = _ref[0], fn = _ref[1]; | ||
} else { | ||
_ref1 = [times, title], title = _ref1[0], fn = _ref1[1]; | ||
} | ||
if (typeof title === 'function') { | ||
fn = title; | ||
title = fn.name; | ||
} | ||
} | ||
} | ||
title = "\"after all\" hook" + (title ? ": " + title : ""); | ||
hook = new RetryHook(times, title, fn); | ||
hook.parent = this; | ||
hook.timeout(this.timeout()); | ||
hook.slow(this.slow()); | ||
hook.ctx = this.ctx; | ||
this._afterAll.push(hook); | ||
this.emit("afterAll", hook); | ||
return this; | ||
}; | ||
Suite.prototype.afterEachWithRetry = function(times, title, fn) { | ||
var hook, _ref, _ref1; | ||
if (this.pending) { | ||
title = "\"after all\" hook" + (title ? ": " + title : ""); | ||
hook = new RetryHook(times, title, fn); | ||
hook.parent = this; | ||
hook.timeout(this.timeout()); | ||
hook.slow(this.slow()); | ||
hook.ctx = this.ctx; | ||
this._afterAll.push(hook); | ||
this.emit("afterAll", hook); | ||
return this; | ||
} | ||
if (title == null) { | ||
fn = times; | ||
title = fn.name; | ||
} else if (fn == null) { | ||
if (typeof times === 'number') { | ||
_ref = [void 0, title], title = _ref[0], fn = _ref[1]; | ||
} else { | ||
_ref1 = [times, title], title = _ref1[0], fn = _ref1[1]; | ||
}; | ||
return Suite.prototype.afterEachWithRetry = function(times, title, fn) { | ||
var hook, _ref, _ref1; | ||
if (this.pending) { | ||
return this; | ||
} | ||
if (typeof title === 'function') { | ||
if (title == null) { | ||
fn = times; | ||
title = fn.name; | ||
} else if (fn == null) { | ||
if (typeof times === 'number') { | ||
_ref = [void 0, title], title = _ref[0], fn = _ref[1]; | ||
} else { | ||
_ref1 = [times, title], title = _ref1[0], fn = _ref1[1]; | ||
} | ||
if (typeof title === 'function') { | ||
fn = title; | ||
title = fn.name; | ||
} | ||
} | ||
if ("function" === typeof title) { | ||
fn = title; | ||
title = fn.name; | ||
} | ||
} | ||
if ("function" === typeof title) { | ||
fn = title; | ||
title = fn.name; | ||
} | ||
title = "\"after each\" hook" + (title ? ": " + title : ""); | ||
hook = new RetryHook(times, title, fn); | ||
hook.parent = this; | ||
hook.timeout(this.timeout()); | ||
hook.slow(this.slow()); | ||
hook.ctx = this.ctx; | ||
this._afterEach.push(hook); | ||
this.emit("afterEach", hook); | ||
return this; | ||
title = "\"after each\" hook" + (title ? ": " + title : ""); | ||
hook = new RetryHook(times, title, fn); | ||
hook.parent = this; | ||
hook.timeout(this.timeout()); | ||
hook.slow(this.slow()); | ||
hook.ctx = this.ctx; | ||
this._afterEach.push(hook); | ||
this.emit("afterEach", hook); | ||
return this; | ||
}; | ||
}; | ||
}).call(this); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32472
450