我有一个用 Coffeescript 编写的 Web 应用程序,我正在使用 nodeunit 进行测试,但我似乎无法访问测试中设置的全局变量(应用程序中的“会话”变量):
src/test.coffee
root = exports ? this
this.test_exports = ->
console.log root.export
root.export
测试/test.coffee
exports["test"] = (test) ->
exports.export = "test"
test.equal test_file.test_exports(), "test"
test.done()
输出结果:
test.coffee
undefined
✖ test
AssertionError: undefined == 'test'
如何跨测试访问全局变量?