업데이트 : 난 여전히 아래와 같은 문제가 받고 있어요,하지만 지금은 다음과 같은 오류가 JSDom하여 콘솔에 게시됩니다 :지도 API
Error: Uncaught [SyntaxError: ]
at reportException (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:58:24)
at processJavaScript (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:130:7)
at HTMLScriptElementImpl._eval (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:65:7)
at e (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:30:22)
at Object.check (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:97:11)
at /Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:116:12
at wrappedEnqueued (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:234:16)
at Request.request [as _callback] (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:184:9)
at Request.self.callback (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/request/request.js:187:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/request/request.js:1044:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Gunzip.<anonymous> (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/request/request.js:965:12)
at emitNone (events.js:91:20)
at Gunzip.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:934:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9) SyntaxError
at XMLHttpRequest.open (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:451:15)
at http://js.api.here.com/v3/3.0/mapsjs-core.js:51:86
at http://js.api.here.com/v3/3.0/mapsjs-core.js:51:383
at http://js.api.here.com/v3/3.0/mapsjs-core.js:290:26
at Object.exports.runInContext (vm.js:44:17)
at processJavaScript (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:128:10)
at HTMLScriptElementImpl._eval (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:65:7)
at e (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:30:22)
at Object.check (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:97:11)
at /Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:116:12
at wrappedEnqueued (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:234:16)
at Request.request [as _callback] (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:184:9)
at Request.self.callback (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/request/request.js:187:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/request/request.js:1044:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Gunzip.<anonymous> (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/request/request.js:965:12)
at emitNone (events.js:91:20)
at Gunzip.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:934:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
나 ' Moha를 사용하여 작성된 테스트 내에서 JavaScript API가 올바르게 작동하도록하려면 여기를 클릭하십시오.
it("should generate a map when the component gets rendered", function generateMapTest(done) {
this.timeout(0);
const scriptMap = getScriptMap();
const scriptNames = Object.keys(scriptMap);
const finalScriptToLoad = last(scriptNames);
getScript(finalScriptToLoad).onLoad((err: any, res?: any) => {
global.H = window.H;
const platform = new H.service.Platform({
app_id: 'app_id',
app_code: 'app_code',
});
console.log(window.H);
done(err);
});
});
위 설명을 위해 - scriptMap 변수는로드 할 각 HERE Maps 스크립트의 URL을 포함하는 객체를 저장하는 데 사용됩니다. 각 스크립트는 자바 스크립트를 사용하여 순차적으로로드되어 jsdom을 사용하여 DOM에 태그를 추가합니다. 각 스크립트가로드되면 콜백 배열에있는 모든 콜백이 호출되어 일반적인 오류 및 응답 객체를 전달합니다. 콜백은 아래 표시된 onLoad 메서드를 사용하여이 배열에 추가됩니다.
마지막 스크립트가 여기 서버에서로드되면 Mocha의 전역 변수에 H 개체를 첨부하고 플랫폼 서비스를 만들려고합니다. 이것은 다음과 같은 오류가 발생합니다 나는이 버그의 원인을 추적 어떤 도움을 줄 수 그래서 만약, 제공되는 코드의 축소 된 버전을 디버깅하기 위해 고군분투
Unhandled rejection TypeError: Cannot read property 'mapsjs-core' of undefined
at Hi (http://js.api.here.com/v3/3.0/mapsjs-core.js:287:626)
at Ji (http://js.api.here.com/v3/3.0/mapsjs-core.js:288:350)
at V.Es (eval at <anonymous> (http://js.api.here.com/v3/3.0/mapsjs-core.js:47:404), <anonymous>:13:188)
at new V (eval at <anonymous> (http://js.api.here.com/v3/3.0/mapsjs-core.js:47:404), <anonymous>:12:257)
at Object.getPlatform (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/src/utils/get-platform.js:9:16)
at /Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/src/HEREMap.js:34:50
at /Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/src/utils/cache.js:52:104
at arrayEach (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/lodash/lodash.js:522:11)
at Function.forEach (/Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/node_modules/lodash/lodash.js:9011:14)
at /Users/joshua/Dropbox/Projects/Web Development/NPM Modules/react-here-maps/src/utils/cache.js:52:30
나는 그것을 감사하겠습니다. 이 모든 것이 여기에 Maps React 구성 요소를 작성하는 컨텍스트에 있음을 알리는 것이 가치가 있습니다. 소스 코드는 https://github.com/josh-es/react-here-maps에서 찾을 수 있습니다.
~^~ 내가 XMLHttpRequest의 API의 JSDom 구현에 문제를 분리 관리