diff --git a/lib/PoolPlus.js b/lib/PoolPlus.js index cb5e8b0..9ef6cfe 100644 --- a/lib/PoolPlus.js +++ b/lib/PoolPlus.js @@ -92,7 +92,7 @@ class PoolPlus extends Pool { */ defineTable(name, schema, migrationStrategy) { if (typeof name !== 'string') { - throw new Error('The table name must be a string'); + throw new TypeError('The table name must be a string'); } if (this._tables.has(name)) { throw new Error(`A table called "${name}" has already been defined for this pool`); diff --git a/test/unit/PoolPlus.test.js b/test/unit/PoolPlus.test.js index 8185436..f4c192d 100644 --- a/test/unit/PoolPlus.test.js +++ b/test/unit/PoolPlus.test.js @@ -103,7 +103,8 @@ describe('PoolPlus', () => { }); it('should throw if the table name is not a string', () => { - should.throws(() => pool.defineTable(/table/), /The table name must be a string/); + (() => pool.defineTable(/table/)).should.throw(TypeError); + (() => pool.defineTable(/table/)).should.throw(/The table name must be a string/); }); it('should throw if no columns are provided', () => {