Node js assert.equal multiple values

2.3k Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

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.

0
On

No dependencies

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

It actually ends up 2 characters less than the chai solution