Asserts that the target function changes the return value of the getter function.
A function that returns a value to monitor
OptionalevalMsg: MsgSourceOptional message to display if the assertion fails
Result that supports .by() chaining
let value = 1;
const getValue = () => value;
const addOne = () => { value++; };
expect(addOne).to.change(getValue);
expect(addOne).to.change(getValue).by(1);
let count = 0;
const getCount = () => count;
const increment = () => { count++; };
expect(increment).to.increase(getCount);
expect(increment).to.increase(getCount).by(1);
Asserts that the target function changes the specified property of the object.
Result that supports .by() chaining
const obj = { val: 10 };
const addTwo = () => { obj.val += 2; };
expect(addTwo).to.change(obj, 'val');
expect(addTwo).to.change(obj, 'val').by(2);
const obj = { count: 5 };
const increment = () => { obj.count++; };
expect(increment).to.increase(obj, 'count');
expect(increment).to.increase(obj, 'count').by(1);
Function signature for change assertions. Can monitor either a getter function or an object property.
Since
0.1.5