Intercept calls to a method to track the arguments, call site, and return/throw status, and replace the implementation.
By default, the method is set to a no-op. To retain the method behavior, pass the current value of the method as the third argument. For example:
const results = t.capture(obj, 'foo', obj.foo)
Automatically restores at t.teardown()
if the @tapjs/after
plugin is not disabled. Otherwise, it is important to call the
restore()
method on the returned function when you are done capturing.
Just wrap the function and return it. Does not have any logic to restore, since it's not actually modifying anything. The results hang off the function as the 'calls' property.
The added fn.args()
method will return an array of the arguments
passed to each call since the last time it was inspected.
Intercept and track object property sets and gets.
If a PropertyDescriptor is set, then it will be used as the replacement value. Otherwise, the original descriptor will be used.
If the strictMode
param is set, then attempts to write to read-only
properties will throw an error.
Implementation class providing the @tapjs/intercept!Interceptor#intercept, @tapjs/intercept!Interceptor#capture, and @tapjs/intercept!Interceptor#captureFn methods.