mocha-cakesrestify 서비스에 대해 실행되는 일부 mocha-cakes 테스트 스크립트에서 타이밍 문제가 발생합니다. Restrict JSON 클라이언트를 사용하여 약속보다는 콜백을 사용하는 호출을 발행합니다. 완성 된 함수를 내 Given
과 When
으로 전달 했으므로 이러한 비동기 호출에 대해 필요한 블로킹을 수행 할 수 있으므로 일관성없는 테스트 스위트 실행을 막을 수 있습니다 (dands가없는 경우, tossup 및 which가 얼마나 많은지 Then
및 And
초).테스트 Mocha-Cakes 및 Coffescript를 사용하여 서비스를 다시 설정하면 비동기에서 done()을 사용하면 시간 초과 문제가 발생합니다.
나는 보통 coffescript에 익숙하며 초보자 만 모카/모카 - 케이크에 관해서는, 그래서 나는 확실히 내 코드에서 뭔가 잘못하고있다. \ 개발 \ 클라이언트가 Pensco을 \ \ AngularJS와 :
C :
require 'mocha-cakes' should = require 'should' restify = require 'restify' Feature "Account API", "In order to have control over structured Account documents", "as a consumer of investment account information,", "I need a RESTful service API.", -> Scenario "GET /account/:userid", -> client = restify.createJSONClient url: "http://localhost:8080", version: "*" _e1 = null _r1 = null _e2 = null _r2 = null _d2 = null # GET non-existent account Given "I have not yet created the Account", -> When "I request the Account", (done) -> client.get "/account/99", (err, req, res, obj) -> _e1 = err _r1 = res done() err Then "it should respond with an error", -> _e1.should.be.ok And "the status code should be 404", -> _r1.should.have.status 404 # GET existent account Given "I have created the Account", (done) -> client.post "/account", { userId: 1, accountType: 0, accountCategories: [], beneficiaries: [], accountOwner: { firstName: "Test", lastName: "User" } }, (err) -> done() err When "I request the Account", (done) -> client.get "/account/1", (err, req, res, obj) -> _e2 = err _r2 = res _d2 = obj done() err Then "it should responond with a document", -> _d2.should.be.ok And "it should have the userId 1", -> _d2.userId.should.eql 1 And "it should have an accountOwner property", -> _d2.accountOwner.should.be.ok And "the status code should be 200", -> _r2.should.have.status 200
내가 이것을 실행하면, 내 출력은 항상 다음과 같다 : 여기서 실패 테스트 케이스의 몇 가지의 예입니다 \ Pensco \ newaccountwizard.api> 모카 테스트/AccountAPITests.coffee -r 사양이 커피 --compilers -R한다 : 커피 스크립트/등록을
기능 : 계정 API
,142 1 실패 3 아직 647,333,2106 전달 (6S)
1) 특징 : 계정 API
In order to have control over structured Account documents as a consumer of investment account information, I need a RESTful service API. Scenario: GET /account/:userid ◦ When: I request the Account: Error: timeout of 2000ms exceeded at [object Object].<anonymous> (C:\Users\Jon\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:139:19) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
2) 특징 : 계정 API
In order to have control over structured Account documents as a consumer of investment account information, I need a RESTful service API. Scenario: GET /account/:userid ◦ Given: I have created the Account: Error: timeout of 2000ms exceeded at [object Object].<anonymous> (C:\Users\Jon\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:139:19) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
3) 특징 : 계정 API
In order to have control over structured Account documents as a consumer of investment account information, I need a RESTful service API. Scenario: GET /account/:userid ◦ When: I request the Account: Error: timeout of 2000ms exceeded at [object Object].<anonymous> (C:\Users\Jon\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:139:19) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
이제 client.get/client.post를 통한 REST 호출이 거의 즉시 발생한다는 것을 알았습니다. 내가 복원 서비스 서버를 다시 시작한 후 첫 번째 실행을 제외하고는 일반적으로 첫 번째 또는 두 번째 Then
/And
만 실패하고 나머지는 성공적으로 완료됩니다. 아마도 몇 밀리 초의 타이밍 문제가 있지만 확실히 2000ms는 아닙니다. 내가 왜 Givens와 Whens가 갑자기 시간을 내기 시작하는지 궁금 하네. 내가 done()
전화를 걸면.
mocha-cakes가 coffescript Feature-> Scenario-> Given/When-> Then/And/...를 describe/it calls로 변환하는 방법을 오해하고 있습니다. 어떻게 든 적용 범위는 모카 - 케이크 스크립트 구조의 성격을 부여받는 것보다 큽니다 의심 스럽습니다 ... 그 범위가 정확히 무엇인지 정확하게 모르겠습니다.