mocha-steps
Advanced tools
Comparing version 0.0.1 to 1.0.0
@@ -12,3 +12,11 @@ global.step = function(msg, fn) { | ||
try { | ||
fn.call(context); | ||
var promise = fn.call(context); | ||
if (promise != null && promise.then != null && promise.catch != null) { | ||
return promise.catch(function(err) { | ||
context.test.parent._bail = true; | ||
throw err; | ||
}); | ||
} else { | ||
return promise; | ||
} | ||
} catch (ex) { | ||
@@ -53,3 +61,5 @@ context.test.parent._bail = true; | ||
if (fn.length === 0) { | ||
if (fn == null) { | ||
it(msg); | ||
} else if (fn.length === 0) { | ||
it(msg, sync); | ||
@@ -56,0 +66,0 @@ } else { |
{ | ||
"name": "mocha-steps", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "Sequential scenarios for Mocha", | ||
"author": "Romain Prieto", | ||
"keywords": ["mocha", "step", "test", "bdd", "scenarios", "sequence"], | ||
"keywords": [ | ||
"mocha", | ||
"step", | ||
"test", | ||
"bdd", | ||
"scenarios", | ||
"sequence" | ||
], | ||
"license": "MIT", | ||
@@ -20,4 +27,4 @@ "main": "lib/step.js", | ||
"devDependencies": { | ||
"mocha": "~1.19.0" | ||
"mocha": "^2.3.4" | ||
} | ||
} |
@@ -54,2 +54,2 @@ # mocha-steps | ||
- Unlike Mocha's `--bail` option, the rest of the test suite will run normally. | ||
- `step()` works with both synchronous and async tests. | ||
- `step()` works with synchronous, async, and promise tests. |
@@ -98,4 +98,27 @@ var EventEmitter = require('events').EventEmitter; | ||
it('is not executed'); | ||
}); | ||
describe('promise', function() { | ||
it('step 1', function() { | ||
return new Promise(function(resolve, reject) { | ||
setTimeout(resolve, 50); | ||
}); | ||
}); | ||
it('step 2', function() { | ||
return new Promise(function(resolve, reject) { | ||
setTimeout(reject, 50); | ||
}); | ||
}); | ||
it('step 3', function() { | ||
return new Promise(function(resolve, reject) { | ||
setTimeout(resolve, 50); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -100,4 +100,28 @@ var EventEmitter = require('events').EventEmitter; | ||
step('is not executed'); | ||
}); | ||
describe('promise', function() { | ||
step('step 1', function() { | ||
return new Promise(function(resolve, reject) { | ||
setTimeout(resolve, 50); | ||
}); | ||
}); | ||
step('step 2', function() { | ||
return new Promise(function(resolve, reject) { | ||
setTimeout(reject, 50); | ||
}); | ||
}); | ||
step('step 3', function() { | ||
return new Promise(function(resolve, reject) { | ||
setTimeout(resolve, 50); | ||
}); | ||
}); | ||
}); | ||
}); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7225
232
1