-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add uvu/spy
package
#10
Comments
Just to give you some example about my idea: const exampleCallback = assert.fn();
exampleCallback("foo", "foobar");
exampleCallback("bar");
// just check if was called
assert.called(exampleCallback);
// check how many times was called
assert.equal(exampleCallback.calls.length, 2)
// or create some facade to previous assert
assert.calledTimes(exampleCallback, 2);
// check if correct params was passed where first array is the called function and the second is the param order
assert.calledWith(exampleCallback.calls[0][0], "foo");
assert.calledWith(exampleCallback.calls[0][1], "foobar");
assert.calledWith(exampleCallback.calls[1][0], "bar"); |
Hey, I don't think this really belongs in assert since it will leading into a full mocking/spying utility. Perhaps I can add that as a |
Nice idea! I think that |
Cool. It might be a while before I can get to that, simply because the Should I put up a sinon example in the meantime? |
I think that's no problem for a while, you already say in the README that |
I too was looking for a small alternative to Sinon or Jest for spy functionality to pair with Uvu. Might I suggest https://github.com/therealparmesh/snoop until Uvu reaches this point in the roadmap? I'm going to publish the first version pretty soon and would greatly appreciate any guidance from the community. |
Looks great @therealparmesh! Awesome alternative (and name 😆)! I think |
Hello @lukeed, I'm solving #9 issue, and when doing the tests I discover that your assert library doesn't have a way to test if some function was called. In other libraries like
jest
we can do it by creating some reference to a mock function (jest.fn()
for example) and after that, check if this function was called. What do you think about this feature?The text was updated successfully, but these errors were encountered: