From e9fb10d2b98bfda89e68404af532e8d8ee58665a Mon Sep 17 00:00:00 2001 From: Michael Floering Date: Mon, 21 Jan 2013 12:28:25 -0500 Subject: [PATCH] Add instructive error message to `importSuites` that could help new users. Fixes issue #261. --- bin/vows | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/vows b/bin/vows index 253157e..ce68ca5 100755 --- a/bin/vows +++ b/bin/vows @@ -571,7 +571,20 @@ function importSuites(files) { //f = path.join(process.cwd(), path.relative(process.cwd(),f)); var obj = require(f); return suites.concat(Object.keys(obj).map(function (s) { - obj[s]._filename = cwdname(f); + try { + obj[s]._filename = cwdname(f); + } catch (e) { + if (e instanceof TypeError && typeof(obj[s]) === 'undefined') { + abort("runner", + "Caught a TypeError while trying to import " + + "suites: a suite is undefined." + + "Check your exports; are you doing something like " + + "exports.suite = vows.describe('foo')." + + "addBatch({}).run()? If so, remove '.run()'"); + } else { + throw e; + } + } return obj[s]; })); }, [])