【发布时间】:2012-04-06 12:30:18
【问题描述】:
我的test/ 的项目充满了mocha 测试:
test/
├── a.coffee
└── b.coffee
说,a.coffee 是
console.log 'Executing A test!'
global.foo = 'FOO'
而b.coffee 是
console.log 'Executing B test!'
console.log 'Expecting foo not defined:', assert.equal(foo, undefined)
执行 mocha 时:
$ mocha --compilers coffee:coffee-script test/*
Executing A test!
Executing B test!
Expecting foo not defined: false
看起来测试共享同一个全局对象(我想避免)...
有没有办法单独执行每个测试?
谢谢。
【问题讨论】:
-
希望我能正确理解您的问题,但您不能为此使用闭包吗?