I'm trying to write tests for a REST API that could return one of two http status codes, both of which I consider to be correct.
For some reason I'm using Frisby 2, the library that's so easy, you don't even need documentation to use it!
Anyway, in Frisby's own unit tests, it compares against a regex:
it('expectHeader should match with regex', function(doneFn) {
mocks.use(['getUser1']);
frisby.fetch(testHost + '/users/1')
.expect('header', 'Content-Type', /json/)
.done(doneFn);
});
Great! So I'll use that:
frisby.fetch('/rest/endpoint', {
method: 'POST',
body: form
})
.expect('status', /201|429/)
Oh dear
assert.strictEqual(received, expected)
Expected value to be (operator: ===):
/201|429/
Received:
429
Message:
HTTP status /201|429/ !== 429
Difference:
Comparing two different types of values. Expected regexp but received number.
What am I doing wrong?