How can I run the same tests twice (or more) but with one thing different #2800
-
Let's say I have this const identity1 = x => x;
const identity2 = y => y; // unused
test('base', t => {
test.is(identity1(555), 555)
}); I want to run this test a second time, but replacing part of it ( Is there any trick other than these 2 options?
In this specific situation, I want to ensure that two implementations are identical, but I suppose it can be applied to anything else (testing multiple websites, multiple sources, etc) |
Beta Was this translation helpful? Give feedback.
Answered by
novemberborn
Aug 7, 2021
Replies: 1 comment
-
I would use a macro: const checkIdentity = (t, fn) => {
t.is(fn(555), 555)
}
checkIdentity.title = (title, fn) => `${title || ''} ${fn.name}`
test('base', checkIdentity, identity1)
test('base', checkIdentity, identity2) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
fregante
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would use a macro: