Open
Description
Description
I'd like to see a slightly simpler means to use the same macro for a large number of tests. Instead of specifying the macro at every call-site, it might be nice to have a test.use(macro)
function that produces a new test
function that will apply the macro to every invocation.
Test Source
import test from 'ava';
function macro(t, input, expected) {
t.is(eval(input), expected);
}
const check = test.use(macro);
check('2 + 2 = 4', '2 + 2', 4);
check('2 * 3 = 6', '2 * 3', 6);
const title = (providedTitle, input, expected) => `${providedTitle} ${input} = ${expected}`.trim();
const checkIt = test.use(macro, title);
checkIt('2 + 2', 4);
checkIt('2 * 3', 6);
If interested, I might find the time to write a PR for this feature.