2017-07-14 58 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,我该怎么做? –

相关问题