모카 리포터에서 테스트 파일 이름을 얻는 방법
-
21-12-2019 - |
문제
모카 리포터에서 현재 테스트의 파일 이름을 얻는 방법이 있습니까?
기저부와 예에서는 아무것도 찾을 수 없었습니다.
해결책
실제로 파일 이름은 이 당김 요청.지금은 Mocha가 가장 일반적으로 Karma 플러그인 (즉, Karma-mocha) 플러그인으로 가장 많이 실행됩니다.), 그리고 12 월 14 일의 말하기,이 플러그인은 파일 이름 정보를 더 전달하지 못합니다.
이 답변을 자체 일관성있게 만들려면 모카에서 스위트 룸이 어떻게 형성되었지만 BDD에서는 유사합니다.
context.suite = function(title, fn){
var suite = Suite.create(suites[0], title);
suite.file = file;
suites.unshift(suite);
fn.call(suite);
suites.shift();
return suite;
};
.
여기에서는 KARMA-MOCHA / lib / adapter.js :
에 적합한 방법이 어떻게 형성되어 있습니다. runner.on('test end', function(test) {
var skipped = test.pending === true;
var result = {
id: '',
description: test.title,
suite: [],
success: test.state === 'passed',
skipped: skipped,
time: skipped ? 0 : test.duration,
log: test.$errors || []
};
var pointer = test.parent;
while (!pointer.root) {
result.suite.unshift(pointer.title);
pointer = pointer.parent;
}
tc.result(result);
});
.
그러나 당신은 무엇을 알고 있습니다, 나는 이것이 Karma-mocha 프로젝트의 기능 요청으로 문제가되는 멋진 일이라고 생각합니다.
제휴하지 않습니다 StackOverflow