diff --git a/lib/test.js b/lib/test.js index ea139cb4a..990d5ca1a 100644 --- a/lib/test.js +++ b/lib/test.js @@ -613,7 +613,7 @@ class Test extends Base { if (Test.prototype[name] || this[name]) throw new TypeError('attempt to re-define `' + name + '` assert') - const ASSERT = (...args) => { + const ASSERT = function (...args) { this.currentAssert = ASSERT if (typeof args[length] === 'object') { args[length + 1] = args[length] diff --git a/test/test.js b/test/test.js index c52fa8107..7bad194e5 100644 --- a/test/test.js +++ b/test/test.js @@ -1031,6 +1031,15 @@ t.test('addAssert', t => { return t.end() }) +t.test('addAssert on prototype', t => { + function foobar (found, message, extra) { + return this.ok(found, message, extra) + } + Test.prototype.addAssert('foobar', 1, foobar) + t.foobar(true, 'this is fine') + t.end() +}) + t.test('spawn', t => { const okjs = path.resolve(__dirname, '../ok.test.js') t.teardown(() => fs.unlinkSync(okjs))