js.spec icon indicating copy to clipboard operation
js.spec copied to clipboard

Integer failure error can be improved

Open arichiardi opened this issue 8 years ago • 2 comments

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.

arichiardi avatar Jun 12 '17 17:06 arichiardi

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!

prayerslayer avatar Jun 12 '17 18:06 prayerslayer

How about this error message @arichiardi? Doesn't PR #54 fix this one too?

mattbishop avatar Nov 22 '17 22:11 mattbishop