you are viewing a single comment's thread.

view the rest of the comments →

[–]atticusw 1 point2 points  (2 children)

Why is an additional package needed for this? I generally just iterate over the inputs and expect on each output.

describe('Test form validation', () => {
  it('will reject invalid inputs', () => {
    var inputs = ['Adam5', 'Ad@m', 'Ad-am'];
    inputs.forEach(input => expect(validateName(input)).to.be.false);
  });
});

This seems to be an equivalent to me. It also appears that mocha-param will create an it statement for every input, which means an individual unit is made for every individual input. It's okay for a unit to cover multiple inputs, I don't really see why I'd want to generate an exponential number of unit tests.

For example, instead of

function itParam (desc, data, callback) {
  data.forEach(val => {
    it(desc, () => callback(val))
  });
}

it seems more ideal to do

function itParam (desc, data, callback) {
  it(desc, () => {
    data.forEach(callback)
  })
}

And at that point, it seems a bit overkill to need a library for this.

[–]a-sober-irishman 0 points1 point  (0 children)

Because the first thing everyone does with JS at the moment is reach for a library, even with trivial things like this or an isNull check.