spying upon a global function using jasmine-node

I am using jasmine-node to do unit testing on javascript code. I have a number of global functions which I would like to spyOn and allow the call to make it though to the original implementation. See the code below as an example.

For a reason I cannot explain, I am seeing an error "globalFunction() method does not exist".

Can someone tell me why jasmine is not able to find this globalFunction method which I understand to be in global scope.

I appreciate the help

var globalFunction = function() {
    console.log('globalFunction');
};

describe("A Global Function", function() {
    jasmine.getEnv().addReporter(new jasmine.ConsoleReporter(console.log));
    it("may be spied upon", function() {
        spyOn(global,'globalFunction').andCallThrough();
        globalFunction();
        expect(globalFunction).toHaveBeenCalled();
    });
});

Here is the output of jasmine-node

$ jasmine-node  --verbose test.spec.js 
Runner Started.
A Global Function : may be spied upon ... 
Failed.
A Global Function: 0 of 1 passed.

A Global Function
  may be spied upon

Failures:

  1) may be spied upon
   Message:
     globalFunction() method does not exist
   Stacktrace:
     undefined

Finished in 0.008 seconds
1 test, 1 assertion, 1 failure


Runner Finished.
1 spec, 1 failure in 0.008s.    

Your globalFunction not global in fact. Remove var keyword to make it global.

globalFunction = function() {
    console.log('globalFunction');
};

In browsers, the top-level scope is the global scope. That means that in browsers if you're in the global scope var something will define a global variable. In Node this is different. The top-level scope is not the global scope; var something inside a Node module will be local to that module.