Skip to content

Commit

Permalink
test: throw on warning when in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Sep 24, 2020
1 parent d218d47 commit b7bdc6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion 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()

Expand Down Expand Up @@ -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();
})
})
4 changes: 4 additions & 0 deletions 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)
}

0 comments on commit b7bdc6b

Please sign in to comment.