-이 답변은 전부는 아니지만, 어려운 부분은 JsTestDriver를 알기에 이치에 맞습니다. 이것은 임베디드 JS 용 테스트 함수가있는 테스트 파일 내부의 함수 여야합니다. -
var url = "/test/<path to your html file>";
var request = new XMLHttpRequest();
request.open('GET', url, false);
request.send(null);
var doc = document.implementation.createHTMLDocument("SomeTitle");
doc.documentElement.innerHTML = request.responseText;
var allScripts = doc.scripts;
var script = allScripts.item(#);//the # is the specific script you want, look up .item()
var scriptline = script.innerHTML.replace(/\s/g, ' ');//everything needs to be in one line
var script2 = document.createElement('script');
script2.innerHTML = sample;
var h = document.getElementsByTagName('head')[0];
h.appendChild (script2);
여러분 모두 환영합니다!