Skip to content

Commit 0231379

Browse files
committed
Core: Throw TypeError instead of Error for invalid test.each() dataset
1 parent ec7d6e7 commit 0231379

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/core/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function Test (settings) {
3838
// - 2: QUnit.test
3939
// - 3: user file
4040
//
41-
// This needs is customised by test.each()
41+
// A notable exception is test.each(), which overrides this.
4242
this.stackOffset = 3;
4343
extend(this, settings);
4444

@@ -939,7 +939,7 @@ function runEach (data, eachFn) {
939939
eachFn(data[key], key);
940940
}
941941
} else {
942-
throw new Error(
942+
throw new TypeError(
943943
`test.each() expects an array or object as input, but
944944
found ${typeof data} instead.`
945945
);

test/main/each.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ QUnit.module('test.each', function () {
1111
QUnit.test.each('test.each fails with non-array input', ['something', 1, undefined, null], function (assert, value) {
1212
assert.throws(function () {
1313
QUnit.test.each('test.each 1D', value, function () { });
14-
});
14+
}, TypeError);
1515
});
1616

1717
// Promise support for test.each() is tested in test/main/promise.js.

0 commit comments

Comments
 (0)