Is there any way to assert that string
is one of array
elements with chai bdd? I couldn't find that in Chai API
expect("bar").to.be.one.of(["bar", "key"]);
翻转支票:
expect(["bar", "key"]).to.include("bar");
Updated for 2021
The answer below prints out a better error message
expect(res.status).to.be.oneOf([400, 401]);
The error message clearly defines what the expected value is and the returned value.
Eg
expect(200).to.be.oneOf([400, 401]);
Returns
AssertionError: expected 200 to be one of [ 400, 401 ]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.