jeudi 31 mai 2018

Jest - expect a variable to be null or boolean

I am developing some tests with Jest for a Node.js backend and I need to check out some values that come from a third party. In some cases those values can come as a boolean or as null.

Right now I am checking the variables that fit that situation with:

expect(`${variable}`).toMatch(/[null|true|false]/);

Is there any better way to check them with Jest built in functions?

Aucun commentaire:

Enregistrer un commentaire