-
Notifications
You must be signed in to change notification settings - Fork 93
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
Custom assertions? #25
Comments
you can simply decorate your spec function: const withFooAssert = specFn => t => specFn(Object.assign(t, {
foo(actual, expected, description = 'foo !') {
const assertResult = {
pass: Object.is(actual, expected),
actual: actual,
expected: expected,
description,
operator: 'foo'
};
this.collect(assertResult); // COLLECT RESULT
return assertResult;
}
}));
// and then when you write your tests:
test('foo bar bim', withFooAssert(t => {
t.foo('var','bar');
})); You can centralize it if you find it troublesome to write the decorator on each test: const test = require('zora');
module.exports = (description, spec) => test(description, withFooAssert(spec)); And require this function instead of zora What is the missing assertion ? might worth add it to the core library |
Snapshot testing jest style that compares a string against a cached version and visual snapshot testing using pixelmatch that compares an image against a cached version. I've run into a bit of an issue with the visual snapshot. I have three values I need to I need to display when the assertion fails, expected, actual, and the difference. The collect function doesn't have any place to put the difference value. Could you either add an additional field ( |
It would be nice if we could extend the assertions object to provide custom assertions.
The text was updated successfully, but these errors were encountered: