2017-07-14 60 views
-2
describe("Prefabs basic", function() { 
    it("It should create simple plrefab", function(done) { 
     var data = { 
      name: "Pre", 
      project: { 
       _id: settings.projectId, 
       name: "PM_40" 
      }, 
      __t: "Prefabs", 
      stage: "planning", 
      multiTrade: { 
       value: false, 
       companies: [] 
      }, 
      owner: { 
       user: { 
        _id: "" 
       }, 
       company: { 
        _id: "" 
       } 
      }, 
      _customStage: "planning", 
      dates: [], 
      dateIndices: { 
       additional: {}, 
       coord: 0, 
       deliver: 1 
      }, 
      fileIndices: [], 
      todoIndices: [0], 
      new_prefab: true, 
      todos: [], 
      items: { 
       fileIndices: [], 
       todoIndices: [], 
       customId: "1", 
       name: "Item0", 
       level: "1", 
       zone: "west" 
      }, 
      keywords: ["This is Prefab"] 
     }; 

     chai 
      .request(server) 
      .post("/v3/prefabs/create") 
      .set("Authorization", settings.authKey) 
      .send(data) 
      .end(function(err, res) { 
       res.should.have.status(200); 
       prefab = res.body; 
       prefabId = res.body._id; 
       console.log(prefab); 
      }); 
    }); 
}); 
+0

如果您希望人們幫助,必須使其可讀性 –

回答

0

我把格式化你的代碼,以便它是稍微更可讀的自由控制檯上 - 一般你會得到你的問題,如果有更好的響應你提出一個容易理解的問題。有了這個說法,你可以使用process.hrtime()在Node中計時。例如,

it('does something', function() { 
    const startTime = process.hrtime(); 
    chai 
     .request(server) 
     .post("/v3/prefabs/create") 
     .set("Authorization", settings.authKey) 
     .send(data) 
     .end(function(err, res) { 
      res.should.have.status(200); 

      const timeDifference = process.hrtime(startTime); 

      console.log(`Request took ${timeDifference[0] * 1e9 + timeDifference[1]} nanoseconds`); 
     }); 
}); 
+0

嗨,亞歷克斯感謝您的回覆。我真的很感激。我有一個問題:如果我想打印Mili秒的time diff interms,我該怎麼做? –