我想知道是否有任何方法可以从内部主题的测试中获得外部主题的返回值。如果这让人困惑,这里有一个例子:
"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?
}
...
}
...发布于 2011-09-01 21:32:02
伪码:
'should contain' : {
topic : function(err, build) {
this.callback(err, build, "wahoo");
return undefined;
},
'some cool css' : function(err, build, wahooString) {
// Where did build go? Can I still access it from this scope?
}
...基本上,您可以在任何子主题中获取以前的主题数据。然后,您需要手动将其传递给誓言。是的,这是一种痛苦。
https://stackoverflow.com/questions/7266973
复制相似问题