2014-02-06 1 views
0

현재 응답 개체에 속성이 있는지 테스트 중입니다. 그러나 존재하지 않으면 test.done()이 호출되지 않기 때문에 다음 테스트는 모든 것을 무릎 꿇게합니다.노드 단위가 이전 오류를보고하게하려면 어떻게해야합니까?

foo.execute(function(error, response) { 

    test.ok(typeof response.request != 'undefined', 
    "The response should have a request property"); 

    test.equal(response.request.method, 'GET', 
    "The request header should reflect the method used."); 

    test.done(); 

}); 

결과는 ....

FAILURES : 실행 취소 테스트 (또는 설정/분해 분석) : -,이 문제를 해결 모든 테스트는 테스트 전화를 확인하려면 PostResourseGetSucceeds

. 완료()

어떻게하면 테스트가 초기 테스트를 계속보고 할 수 있습니까? 나는 if 문을 넣으려고 시도했지만 성가신 것 같다.

답변

0

나는 간단한 해결책에 넘어졌다.

foo.execute(function(error, response) { 

    try { 

    test.ok(typeof response.request != 'undefined', 
     "The response should have a request property"); 

    test.equal(response.request.method, 'GET', 
     "The request header should reflect the method used."); 

    } 
    catch(e) { 
    test.ok(false, "Not all tests were run."); 
    }; 

    test.done(); 

});