실행하려면 (npm run test
명령을 사용하고 디버그하려면 IDE Webstorm
사용) 노드를 사용하여 통합 테스트를 개발했습니다. typescript, mocha, chai 및 supertest로 작성된 .js는 typescript를 사용하여 개발 된 노드 응용 프로그램 용입니다.async/await 노드 API 함수에 typescript, Mocha, Chai 및 SuperTest를 사용하여 nodeJs를 사용하여 통합 테스트 실행 또는 디버그
before() 후크 함수에서 실제로 서비스를 시작하는 응용 프로그램을 호출하고 있으며이 호출은 비동기 (async-await 사용) 함수 (노드 응용 프로그램의 app.ts/app.js 파일에서 호출)입니다.).
하지만 항상 내가 같은 오류가 점점 오전 '오류 : Google은 KMS에서 당신은 키에 액세스 할 수있는 권한이 없습니다'(즉, 서비스) 및 플러스는 말했다 는 오류 : 60000ms의 제한 시간을 초과했습니다. 비동기 테스트 및 후크의 경우 "done()"이 호출되었는지 확인합니다. Promise를 반환하는 경우이를 확인하십시오. '하지만 서비스/응용 프로그램을 개별적으로 실행하면 정상적으로 작동합니다. 그래서 서비스를 실행하는 동안 API/함수 호출을위한 async/await 코드는 동일합니다.
내 포인트는 before() 후크 기능에서 서비스를 시작하는 동안 비동기/대기 요청으로 인해 시간 초과로 발생합니다. 다음은
는import {expect} from "chai";
const app = require('../app');
const supertest = require('supertest');
describe("Test model", function() {
this.timeout(60000);
before(async() => {
api = supertest(await app);
// app is here a entry point for my service/application which runs actually service/applicaiton.
// This file has async-await function which makes call to third party application
console.log('inside before: ', JSON.stringify(api));
});
describe('get', function() {
it('should respond with 200 Success', async() => {
// call to async function
});
});
});
및 package.json의 섹션 스크립트에서
는"scripts": {
"test": "nyc --reporter=html --reporter=text --reporter=cobertura node_modules/mocha/bin/_mocha --reporter mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters.config build/test/test.int-test.js"
}
사람이 이러한 상황에 직면 할 수, test.int-test.ts 파일에 코드 샘플입니까? 통합 테스트 파일에서 비동기/대기 서비스를 시작하는 방법.