Remove duplicated functions inside different if within a function?
The only difference between the two parts is that the second part has an additional parameter 1? You can provide an array with the original param, if function.length is 2, push 1 into it. the just call func.apply(null, params).
Here is a solution base on the idea:
function __throwError (func) {
  const testcases = [
    new TestCase(func, 0, 'The parameter should be an array'),
    new TestCase(func, 'item', 'The parameter should be an array'),
    new TestCase(func, [], 'The array is empty'),
    new TestCase(func, undefined, 'The parameter is null or undefined'),
    new TestCase(func, null, 'The parameter is null or undefined')
  ];
  if (func.length === 2) {
    testcases.forEach(testcase =&gt; testcase.value.push(1));
  }
  for (const testcase of testcases) {
    expect(testcase.fn).toThrowError(testcase.errMsg);
  }
}

class TestCase {
  constructor (testFn, value, errMsg) {
    this.value = [value];
    this.errMsg = errMsg;
    this.testFn = testFn;
  }
  fn () {
    this.testFn.apply(null, this.value);
  }
}
```