dimanche 19 mai 2019

How to test a function from a list of values in jest?

I'm trying to test my translation function and want to test it against muliple inputs (string) to assure it works. The function should translate a input to the "robber language".

I want to test a dataset (array or list) to prove that the code is working.

I found the test.each method but i dont think im using it right.

let testInput = [['hello'], ['world']]

test.each(testInput)('translate the input to robber language', (input, expected) => {
  expect(translation.translateToRobberLanguage(input)).toEqual(expected)
})


This is what the terminal is giving me as error.

expect(received).toEqual(expected) // deep equality

    Expected: [Function next]
    Received: "hohelollolo"

Aucun commentaire:

Enregistrer un commentaire