을 수정하십시오. 여기에 설명 된 것과 동일한 문제입니다 : https://github.com/facebook/jest/issues/2980. done()
은 오류로 인해 호출되지 않으므로 jamsin 시간 초과에 도달했습니다. 괜찮아. 하지만 재 스민/농담이 그 일이 일어난 오류를보고해야한다는 것은 좋지 않습니다.jest : Promise에서 오류 메시지가 표시됩니다.
참고 : 예제 소스 코드는 here입니다. 그래서 오류가 을해야의 xxx
변수가 정의되지 않습니다
는 Promise
을 만들고 다음 함수를 고려하고, 약속 해결하는 done
콜백 호출합니다
// file: foo.js
function foo(done) {
const p = new Promise((resolve, reject) => {
setTimeout(() => {
//const xxx = 2;
resolve(xxx);
}, 100);
});
p.then(data => {
console.log(data);
done()
})
}
exports.foo = foo;
그것은 오류가 있습니다를 높인.
나는 수입이 기능을 실행하고 스크립트를 실행하면 :
// file: index.js
const foo = require('./foo').foo;
foo(() => {});
와 node v8.6.0
으로 스크립트 실행
node index.js
내가 (
ReferenceError: xxx is not defined
)을 예상 오류 :
을
/home/dfroger/repo/dfroger/issue/jest-promise-error/foo.js:5
resolve(xxx);
^
ReferenceError: xxx is not defined
at Timeout.setTimeout [as _onTimeout] (/home/dfroger/repo/dfroger/issue/jest-promise-error/foo.js:5:21)
at ontimeout (timers.js:469:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:264:5)
지금은에 대한 단위 테스트를 작성합니다. 10 :
// file: foo.test.js
const foo = require('./foo').foo
describe('async',() => {
it('run foo', done => {
foo(done);
});
});
그리고 jest v21.2.1
그것을 실행하지 :
./node_modules/.bin/jest
나는 더 많은 오류 메시지에 대한 xxx being not defined
받을 번호 :
async
✕ run foo (5004ms)
● async › run foo
Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at node_modules/jest-jasmine2/build/queue_runner.js:64:21
at ontimeout (timers.js:469:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:264:5)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 5.574s, estimated 6s
Ran all test suites.
내가 놓친 건가은 jest
를 사용? 버그 jest
입니까? jest
이 항상 오류 메시지를 올바르게보고하는지 어떻게 확인할 수 있습니까?