diff --git a/test/argsert.cjs b/test/argsert.cjs index 7f6e4a04a..d954f696d 100644 --- a/test/argsert.cjs +++ b/test/argsert.cjs @@ -1,7 +1,7 @@ /* global describe, it */ const { argsert } = require('../build/index.cjs') const { checkOutput } = require('./helpers/utils.cjs') -const { should } = require('chai') +const { expect, should } = require('chai') should() @@ -164,4 +164,15 @@ describe('Argsert', () => { o.warnings.length.should.equal(0) }) + + // See: https://github.com/yargs/yargs/issues/1666 + it('should throw on warnings, when under test', () => { + function foo (...args) { + argsert('<*>', [].slice.call(args)) + } + + expect(() => { + foo('bar', undefined, undefined, 33) + }).to.throw(); + }) }) diff --git a/test/before.cjs b/test/before.cjs index 1bbdeed41..62b8091ff 100644 --- a/test/before.cjs +++ b/test/before.cjs @@ -1,2 +1,6 @@ 'use strict' process.env.LC_ALL = 'en_US' +// See: https://github.com/yargs/yargs/issues/1666 +console.warn = (message) => { + throw Error(message) +}