createProxy() function
Creates a Proxy around a value
.
Signature:
declare function createProxy<T>(value: T, parent?: Proxy<unknown>, path?: string): Proxy<T>;
Parameters
Parameter | Type | Description |
---|---|---|
value | T | The inner value of the proxy |
parent | Proxy<unknown> | (Optional) The proxy that created this proxy (parent), or undefined if it doesn't have a parent. |
path | string | (Optional) The index on the |
Returns:
Proxy<T>
The newly created Proxy
Remarks
You can also use the withProxy() method to invoke a callback with the result; depending on your style.
Example
expect(createProxy(myObject).parent.cars).to.be.empty();
Error message:
Expected parent.cars to be empty, but it had 2 elements.