Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node js assert.equal multiple values

Is it possible to use assert.equal method in Node.js like this:

assert.equal(some_var, 12 OR 34);

If some_var is 12 or 34 I need the test to have passed.

like image 948
Rattrap Avatar asked Sep 30 '26 03:09

Rattrap


2 Answers

you can do like this

expect([12, 34]).to.include(some_var);

i usually use chai to do unit test, but the concept should be the same.

like image 87
Alongkorn Avatar answered Oct 01 '26 20:10

Alongkorn


No dependencies

assert([12, 34].includes(some_var));

It actually ends up 2 characters less than the chai solution

like image 45
joshuakcockrell Avatar answered Oct 01 '26 18:10

joshuakcockrell