js.spec
js.spec copied to clipboard
Integer failure error can be improved
Hello again, just logging here a potential improvement of the error message for s.spec.number.
I have:
const school = s.spec.map("schoolSpec", {
city: s.string
});
const friend = s.spec.map("friendSpec", {
name: s.spec.string,
age: s.spec.number,
school
});
and (using the new js-spec-chai:
it("test", () => {
const obj = {
name: "andrea",
age: "18",
school: {
city: "Turin",
}
};
obj.should.conform(friend);
})
I receive AssertionError: friendSpec → i: i failed for 18 at [age]. which could be improved to AssertionError: friendSpec → age: s.spec.number failed for 18 at [age]. for instance.
Interesting, I was under the impression it should read one of isInteger, int or integer instead of i. Looks like I should test my getName properly 😅
Thanks for reporting!
How about this error message @arichiardi? Doesn't PR #54 fix this one too?