Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Catch errors when loading helpers #264

Merged
merged 1 commit into from

2 participants

@pimterry

If a helper script fails to load, currently jasmine-node immediately and silently dies, with no output. This is very unhelpful! This patch makes it fail fast with the error message & offending file logged to the console (along with some tiny bits of whitespace tidy up)

@tebriel

Thanks. LGTM

@tebriel tebriel merged commit dfa2e18 into mhevery:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 22, 2013
  1. @pimterry
This page is out of date. Refresh to see the latest.
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];
+ }
}
};
Something went wrong with that request. Please try again.