array-override
The array-override overrides functions under Array.prototype to change their behaviour according to the given parameters.
Parameters
|
Name |
Description |
Mandatory |
Default |
|---|---|---|---|
|
method |
The Array function to override: |
Yes |
n.a. |
|
needle |
The string or regex used to determine which function calls to trap. Enclose in |
Yes |
n.a. |
|
returnValue |
Only relevant for |
No |
false |
|
path |
Enables "object checking mode" and looks for needle at that given path. |
No |
'' |
|
stack |
Comma separated list of strings to check in the stack trace. |
No |
'' |
Filter examples
|
Filter |
Result |
|---|---|
|
|
Ignores |
|
|
Ignores the call if the parameter starts with "first" and ends with "second". |
|
|
|
|
|
|
|
|
Ignores array forEach when value equals "test". |
|
|
Ignores |
Debugging
|
Message |
When |
Definition |
|---|---|---|
|
|
After wrapping |
push calls are intercepted. |
|
|
After wrapping |
includes calls are intercepted. |
|
|
Needle matches push call |
The push call was ignored. |
|
|
Needle matches includes call |
includes returned the overridden value. |