False positives with body validation
Schoonology opened this issue · comments
I'm currently working on migrating an existing API to a new tech stack. As a part of that process I created a Frisby-based characterization test suite, and intend to test-drive the migration. However, tests are passing under two circumstances that seem incorrect to me:
- If the
Content-Type
is notapplication/json
-ish (I'm using JSON:API), such as it's blank, the test passes with ajsonTypesStrict
assertion. - If the response body is empty but contains an appropriate
Content-Type
header, the test passes with ajsonTypesStrict
assertion.
Are these by design? If so, how can I guarantee these tests fail when the body is the incorrect type or missing?
If the
Content-Type
is notapplication/json
-ish (I'm using JSON:API), such as it's blank, the test passes with ajsonTypesStrict
assertion.
I think that you should test Content-Type
the last. (like this test)
If the response body is empty but contains an appropriate
Content-Type
header, the test passes with ajsonTypesStrict
assertion.
Will be fixed this issue by #510.
Workaround until released.
.expect('jsonTypesStrict', Joi.object({
name: Joi.string(),
email: Joi.string().email(),
body: Joi.string()
}).required()) // <- use required()
@H1Gdev Before I file a second issue, is this related to false positives with missing keys? I currently have a response body missing a key, and the test is passing.
If JSON is undefined validator will not be an error.