2017-02-27 5 views
1
import React from 'react'; 
import CrudApi from '../api/CrudApi'; 
import nock from 'nock'; 

describe('CrudList Component',() => { 

    it('should have users',() => { 

     afterEach(() => { 
      nock.cleanAll() 
     }) 

     CrudApi.getAll().then(
      data => {expect(data).toHaveLength(9) // this failed 
      console.log(data.length) // 10} 
     ) 
    }); 
}); 

getAll이 10 개의 배열을 반환하기 때문에 테스트 케이스에 해당하지 않습니다. 내 cmd를 나는 테스트를 통과보고 있어요?시험에 합격 했음에도 불구하고 시험에 합격 했음에도 불구하고 시험 합격

it('should have users',() => { 

    afterEach(() => { 
     nock.cleanAll() 
    }) 

    return CrudApi.getAll().then(
     data => {expect(data).toHaveLength(9) // this failed 
     console.log(data.length) // 10} 
    ) 
}); 
: 당신이 it 함수의 약속을 반환해야 -이 기다리고 있지 않기 때문에

enter image description here

답변

3

이 시험은 약속 해결하기 위해 자사의 통과를 나타냅니다