felixge / node-sandboxed-module

A sandboxed node.js module loader that lets you inject dependencies into your modules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot stub globals in coffeescript

Almad opened this issue · comments

Maybe I am doing something wrong, but I cannot stub globals in CS.

Failing test is here: Almad@adacbb8

You are creating a local variable named BASE with value 1 inside your CoffeeScript file, that is shadowing the global variable named BASE introduced by sandboxed-module.

Remember that simply assigning variableName = value in CoffeeScript creates local variables, not global ones.


Even if you did change it to global.BASE = 1, your test would still not work, since you'd just be overwriting global.BASE (which had value 5) with the value 1.

You need to remove all assignments to BASE inside your CoffeeScript file to see the effect.