-
Notifications
You must be signed in to change notification settings - Fork 5
test async functions #19
Comments
Hi @FrontMage, thanks for the question! I think you need to const expect = require('chai').expect;
exports.default = (
testDescription,
func,
argsArray,
expected,
test
) => {
test(testDescription, () => {
return func.apply(null, argsArray)
.then(actual => {
expect(actual).to.eql(eval(`var trouble = ${expected}; trouble`));
});
});
}; I've created a sample repo here with a working test: https://github.com/nadeesha/saul-async-test Does that answer your question? |
This did answer my question. I've encountered another problem, the async function I tried to test to returns a considerably large json, written them into one single line makes it very hard to read. |
Of course! Please.
Yes, if the payload is serializable, and large, you could do a snapshot test: https://github.com/nadeesha/saul#matches-snapshot // @t "returns correct json" myLargeJSONFunc() ~matches-snapshot |
Hi, I've been using
saul
to test my code, it's really fantastic.However when testing with asyn functions, I wrote an test engine like this:
It suppose to act like
deep-equals
with function returns promise, but it's not working and it did not throw any error.Could you help me with this? Thanks :)
The text was updated successfully, but these errors were encountered: