Vows.js:访问内部主题内外部主题返回的参数
我想知道是否有任何方法可以从内部主题的测试中获取外部主题的返回值。如果这令人困惑,这里有一个例子:
"build.css" : {
topic : function(file) {
fs.readFile(fixtures + "/public/build.css", "utf8", this.callback);
},
'exists' : function(err, build) {
assert.isNull(err); // This is fine..
},
{
'should contain' : {
topic : function() {
return "wahoo";
},
'some cool css' : function(wahooString, err, build) {
// Where did build go? Can I still access it from this scope?
}
...
}
...
I was wondering if there is any way to obtain the return value of an outer topic, from within a test of an inner topic. If that was confusing, here's an example:
"build.css" : {
topic : function(file) {
fs.readFile(fixtures + "/public/build.css", "utf8", this.callback);
},
'exists' : function(err, build) {
assert.isNull(err); // This is fine..
},
{
'should contain' : {
topic : function() {
return "wahoo";
},
'some cool css' : function(wahooString, err, build) {
// Where did build go? Can I still access it from this scope?
}
...
}
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
伪代码:
基本上,您可以在任何子主题中获取之前的主题数据。然后您需要手动将其传递给誓言。是的,这是一种痛苦。
Pseudo Code:
Basically you get the previous topics data in any sub topic. You then need to manually pass it to the vows. Yes it is a pain.