簡體   English   中英

Vows.js:訪問內部主題內部主題返回的參數

[英]Vows.js: Accessing parameters returned from outer topics inside inner topics

我想知道是否有任何方法可以從內部主題的測試中獲取外部主題的返回值。 如果這令人困惑,請舉一個例子:

"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?
      }
    ...
  }
  ...

偽代碼:

'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?
  }
...

基本上,您可以在任何子主題中獲得先前的主題數據。 然后,您需要將其手動傳遞給誓言。 是的,這很痛苦。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM