Used to convert jest's Tagged Template literals to object arrays as required by vitest. Example: Jest code
it.each`
str | expected
${'1d'} | ${moment.duration(1, 'd')}
${'2w'} | ${moment.duration(2, 'w')}
`('should parse $str to $expected duration', ({ str, expected }) => {
expect(yourFunction(str)).toEqual(expected);
});
Vitest code
it.each(convert`
str | expected
${'1d'} | ${moment.duration(1, 'd')}
${'2w'} | ${moment.duration(2, 'w')}
`)('should parse $str to $expected duration', ({ str, expected }) => {
expect(yourFunction(str)).toEqual(expected);
});
This is just a simple hack to support easy migration of jest to vitest. This was tested only on tests in Mermaid repo.
Template literal support has been avoided intentionally in Vitest, this is only meant as a stop-gap.