Skip to content
Browse files

Catch errors when loading helpers

  • Loading branch information...
1 parent 97d8c9d commit dcf57665b5f8a387db9c2c5deb9d55a778c8b6ba @pimterry pimterry committed
Showing with 14 additions and 6 deletions.
  1. +14 −6 lib/jasmine-node/index.js
View
20 lib/jasmine-node/index.js
@@ -36,26 +36,34 @@ jasmine.TerminalVerboseReporter = nodeReporters.TerminalVerboseReporter;
jasmine.TerminalReporter = nodeReporters.TerminalReporter;
-jasmine.loadHelpersInFolder=function(folder, matcher)
-{
+jasmine.loadHelpersInFolder = function(folder, matcher) {
// Check to see if the folder is actually a file, if so, back up to the
// parent directory and find some helpers
folderStats = fs.statSync(folder);
if (folderStats.isFile()) {
folder = path.dirname(folder);
}
+
var helpers = [],
helperCollection = require('./spec-collection');
helperCollection.load([folder], matcher);
helpers = helperCollection.getSpecs();
- for (var i = 0, len = helpers.length; i < len; ++i)
- {
+ for (var i = 0, len = helpers.length; i < len; ++i) {
var file = helpers[i].path();
- var helper= require(file.replace(/\.*$/, ""));
- for (var key in helper)
+
+ try {
+ var helper = require(file.replace(/\.*$/, ""));
+ } catch (e) {
+ console.log("Exception loading helper: " + file)
+ console.log(e);
+ throw e; // If any of the helpers fail to load, fail everything
+ }
+
+ for (var key in helper) {
global[key]= helper[key];
+ }
}
};

0 comments on commit dcf5766

Please sign in to comment.
Something went wrong with that request. Please try again.