From f3f955006019a4269bebfb52d3e51f282cc43438 Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Sat, 25 Feb 2017 12:22:15 -0800 Subject: [PATCH] chore: add failing test for #794 --- test/command.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/command.js b/test/command.js index 8c6df70bb..1e7fd6bc5 100644 --- a/test/command.js +++ b/test/command.js @@ -1100,6 +1100,20 @@ describe('Command', function () { }) .argv }) + + // addresses https://github.com/yargs/yargs/issues/794 + it('should bubble errors thrown by coerce function inside commands', function (done) { + yargs + .command('foo', 'the foo command', (yargs) => { + yargs.coerce('x', function (arg) { + throw Error('yikes an error') + }) + }) + .parse('foo -x 99', function (err) { + err.message.should.match(/yikes an error/) + return done() + }) + }) }) describe('defaults', function () {