jest-zone-patch
Advanced tools
Comparing version
29
index.js
@@ -54,18 +54,32 @@ /** | ||
const bindDescribe = (originalJestFn) => function () { | ||
const eachArguments = arguments; | ||
return function (description, specDefinitions, timeout) { | ||
arguments[1] = wrapDescribeInZone(specDefinitions) | ||
return originalJestFn.apply(this, eachArguments).apply( | ||
this, | ||
arguments | ||
) | ||
} | ||
}; | ||
['xdescribe', 'fdescribe', 'describe'].forEach(methodName => { | ||
const originaljestFn = env[methodName]; | ||
env[methodName] = function(description, specDefinitions) { | ||
return originaljestFn.call( | ||
env[methodName] = function(description, specDefinitions, timeout) { | ||
arguments[1] = wrapDescribeInZone(specDefinitions) | ||
return originaljestFn.apply( | ||
this, | ||
description, | ||
wrapDescribeInZone(specDefinitions) | ||
arguments | ||
); | ||
}; | ||
env[methodName].each = bindDescribe(originaljestFn.each); | ||
if (methodName === 'describe') { | ||
env[methodName].only = env['fdescribe']; | ||
env[methodName].skip = env['xdescribe']; | ||
env[methodName].only.each = bindDescribe(originaljestFn.only.each); | ||
env[methodName].skip.each = bindDescribe(originaljestFn.skip.each); | ||
} | ||
}); | ||
['xit', 'fit', 'test', 'it'].forEach(methodName => { | ||
['xit', 'fit', 'xtest', 'test', 'it'].forEach(methodName => { | ||
const originaljestFn = env[methodName]; | ||
@@ -76,5 +90,10 @@ env[methodName] = function(description, specDefinitions, timeout) { | ||
}; | ||
// The revised method will be populated to the final each method, so we only declare the method that in the new globals | ||
env[methodName].each = originaljestFn.each; | ||
if (methodName === 'test' || methodName === 'it') { | ||
env[methodName].only = env['fit']; | ||
env[methodName].only.each = originaljestFn.only.each; | ||
env[methodName].skip = env['xit']; | ||
env[methodName].skip.each = originaljestFn.skip.each; | ||
} | ||
@@ -81,0 +100,0 @@ }); |
{ | ||
"name": "jest-zone-patch", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Enables Jest functions to be run within Zone.js context", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
6040
15.82%95
21.79%