2017-11-16 8 views
0

입니다. 나는 노드 js 테스트 케이스를 작성하는 데 chai.should();을 사용하고 있습니다. 나는 REST API를 호출하고 나는 응답 상태 코드를 테스트 할오류 가져 오기 알 수없는 AssertionError : 예상되는 {}의 '데이터'속성이

{ 
    "statuscode": 200, 
    "message": "success", 
    "data": { 
    "getEducationDetails": [ 
     { 
     "end_date": "1996-04-31", 
     "degree_name": "BE", 
     "degree_date": "1993-06-18", 
     "location": "Hyderabad", 
     "university_name": "Hyderabad", 
     "institute_name": "VIT", 
     "start_date": "1992-01-01" 
     } 
    ] 
    } 
} 

200 여부 등 위치

같은 예절 내가

res.body.should.have.property('data') 
        .which.is.an('object') 
        .and.has.property('getEducationDetails') 
        .which.is.an('array') 
        .and.has.property('location') 
    .and.has.property('location') 

을 시도하고있는 반응을 얻고있다 stauscode 용

res.body.should.have.property('stauscode').eql(200) 

이러한 속성을 테스트하려면 어떻게해야합니까?

은 사전

답변

0

https://www.npmjs.com/package/chai-things

그것은 종료일을 포함해야 배열의 모든 개체를 확인합니다에 감사합니다. 모든 부동산에 대해 할 수 있습니다.

res.body.data.getEducationDetails.should.all.have.property('end_date')