ealush / vest

Vest ✅ Declarative validations framework
https://vestjs.dev/
MIT License
2.57k stars 84 forks source link

Done and empty suite #1092

Closed vonagam closed 1 year ago

vonagam commented 1 year ago

If we have this:

const vest = require("vest")

const suite = vest.create(() => {
  vest.test("foo", () => {});
});

const result = suite();

result.done(() => {
  console.log("done");
});

We will see "done" being printed.

Now, if we add vest.optional({foo: true}) before vest.test or remove vest.test altogether then the suite will run but there will be no done call.

In my use case it was something like vest.optional({name: data.name === current.name}) to avoid running tests on a name field unless it was changed.

ealush commented 1 year ago

I think you are right. Unless targeting specifically a nonexistent fieldname (eg: .done('bla', () => {...})), done should always run at the end of the suite, even if it turned out to be empty, or without any tests actually running. Let me sort it out one moment.

ealush commented 1 year ago

There you go. vest@5.1.1 should have it fixed. https://github.com/ealush/vest/commit/e889bd7606b599efcd0f3344aaef33c0b38d6ba8

vonagam commented 1 year ago

Thanks!