2017-12-15 2 views
1

각도 cli로 생성 된 프로젝트가 있습니다. cli로 새로운 구성 요소를 생성하고 다음 스택과 함께 PhantomJS를 사용할 때도 가장 기본적인 테스트가 실패합니다.자스민 단위 테스트는 Chrome에서 실행되지만 PhantomJs에서는 실행되지 않습니다.

× should create an instance 
    PhantomJS 2.1.1 (Windows 8 0.0.0) 
    Failed: undefined is not a constructor (evaluating 'attr.name.startsWith(_I18N_ATTR_PREFIX)') 
    http://localhost:9876/_karma_webpack_/vendor.bundle.js:48660:70 
    [email protected][native code] 
    [email protected]://localhost:9876/_karma_webpack_/vendor.bundle.js:48660:24 
    [email protected]://localhost:9876/_karma_webpack_/vendor.bundle.js:48603:32 
    [email protected]://localhost:9876/_karma_webpack_/vendor.bundle.js:40053:62 
    http://localhost:9876/_karma_webpack_/vendor.bundle.js:48595:59 
    [email protected][native code] 
    [email protected]://localhost:9876/_karma_webpack_/vendor.bundle.js:48594:31 
    [email protected]://localhost:9876/_karma_webpack_/vendor.bundle.js:40053:62 
    http://localhost:9876/_karma_webpack_/vendor.bundle.js:48595:59 
    [email protected][native code] 
    [email protected]://localhost:9876/_karma_webpack_/vendor.bundle.js:48594:31 
    [email protected]://localhost:9876/_karma_webpack_/vendor.bundle.js:40053:62 
    http://localhost:9876/_karma_webpack_/vendor.bundle.js:48595:59 
    [email protected][native code] 
    [email protected]://localhost:9876/_karma_webpack_/vendor.bundle.js:48594:31 

나는 npm 패키지의 조합과 약간의 비 호환성이 있다고 생각합니다. 여기 내 패키지입니다 .json

"dependencies": { 
"@angular/animations": "^5.0.2", 
"@angular/common": "^5.0.2", 
"@angular/compiler": "^5.0.2", 
"@angular/core": "^5.0.2", 
"@angular/forms": "^5.0.2", 
"@angular/http": "^5.0.2", 
"@angular/platform-browser": "^5.0.2", 
"@angular/platform-browser-dynamic": "^5.0.2", 
"@angular/router": "^5.0.2", 
"angularfire2": "^5.0.0-rc.4", 
"core-js": "^2.4.1", 
"crds-styles": "^1.3.1", 
"firebase": "^4.6.2", 
"intl": "^1.2.5", 
"ng2-toastr": "^4.1.2", 
"ngx-bootstrap": "1.9.3", 
"rxjs": "^5.5.2", 
"zone.js": "^0.8.14" 
}, 
"devDependencies": { 
"@angular/cli": "1.5.4", 
"@angular/compiler-cli": "^5.0.2", 
"@angular/language-service": "^5.0.2", 
"@types/jasmine": "2.5.38", 
"@types/jasminewd2": "~2.0.2", 
"@types/node": "~6.0.89", 
"codelyzer": "^4.0.1", 
"firebase-tools": "^3.15.4", 
"jasmine-core": "~2.6.0", 
"jasmine-spec-reporter": "~4.2.0", 
"karma": "~1.7.0", 
"karma-chrome-launcher": "~2.1.1", 
"karma-cli": "~1.0.1", 
"karma-coverage-istanbul-reporter": "^1.2.1", 
"karma-jasmine": "~1.1.0", 
"karma-jasmine-html-reporter": "^0.2.2", 
"karma-mocha-reporter": "2.2.4", 
"karma-phantomjs-launcher": "^1.0.4", 
"karma-teamcity-reporter": "^1.0.0", 
"prettier": "^1.9.2", 
"protractor": "~5.1.2", 
"replace": "^0.3.0", 
"ts-node": "~2.0.0", 
"tslint": "~5.7.0", 
"tslint-config-prettier": "^1.6.0", 
"typescript": "2.5.3" 
} 

아이디어가 있으십니까?

답변

0

ECMAScript 6에 도입 된 startsWith() 메서드를 사용합니다. 현재 Phantom JS는이 JS 버전을 지원하지 않습니다. 현재 상태는 https://github.com/ariya/phantomjs/issues/14506입니다. 대신 ChromeHeadless를 사용하거나 ES6 코드가 포함 된 파일을 건너 뛸 수 있습니다 (단, 테스트되지는 않습니다).

+0

테스트하기 전에 ES5로 번역 할 수 있지만 phantomjs는 더 이상 유지 관리되지 않습니다. (https://groups.google.com/forum/#!topic/phantomjs/9aI5d-LDuNE) 다른 것으로 전환하십시오. – ext

관련 문제