lundi 11 janvier 2021

Is there an equivalent function for `test.each` from Jest in Chai?

Jest provides the test.each function, that allows nice testing of a table driven test input matrix via tagged templates. Is there an equivalent function / plugin available for Chai? I did search through the Chai Plugins but could not find something similar.

Actually this could be also solved with a generic solution, regardless of the used assertion / test runner, however the only ones (Sazerac, Mocha Table, Chai Things) I've found are either using fluent APIs or work on arrays, whereas I like to have them basically work with super-charged markdown tables:

const testInput = 
`| enableMixed | oldValue   | newValue   | emitChange |
 | ----------- | --------   | --------   | ---------- |
 | ${false}    | ${false}   | ${false}   | ${false}   |
 | ${false}    | ${false}   | ${true}    | ${true}    |
 | ${false}    | ${false}   | ${'mixed'} | ${false}   |
`

Aucun commentaire:

Enregistrer un commentaire