2014-03-26 306 views
2

我想寫一些單元測試。我得到的角度是不確定的錯誤,所以我想我需要包括的角度js文件與我的其他js文件......爲此我試圖NPM安裝...測試AngularJS與業力和茉莉花

{ 
    "name": "jzAddons", 
    "description": "A collection of addons for AngularJS", 
    "version": "0.0.1", 
    "private": false, 
    "devDependencies": { 
    "angularjs": "git://github.com/angular/angular.js.git", 
    "grunt": "0.4", 
    "grunt-contrib-jshint": "0.7.2", 
    "grunt-contrib-stylus": "0.10.0", 
    "grunt-contrib-uglify": "0.2.7", 
    "grunt-contrib-clean": "0.5.0", 
    "grunt-karma": "*", 
    "karma": "~0.12", 
    "karma-chrome-launcher": "*", 
    "karma-jasmine": "*", 
    "karma-phantomjs-launcher": "*" 
    } 
} 

npm install失敗:

> npm install 
npm WARN package.json [email protected] No repository field. 
npm http GET https://registry.npmjs.org/grunt-contrib-uglify/0.2.7 
npm http GET https://registry.npmjs.org/grunt-contrib-jshint/0.7.2 
npm http GET https://registry.npmjs.org/grunt-contrib-stylus/0.10.0 
npm http GET https://registry.npmjs.org/grunt-contrib-clean/0.5.0 
npm http GET https://registry.npmjs.org/grunt-karma 
npm http GET https://registry.npmjs.org/grunt 
npm http GET https://registry.npmjs.org/karma-chrome-launcher 
npm http GET https://registry.npmjs.org/karma-jasmine 
npm http GET https://registry.npmjs.org/karma-phantomjs-launcher 
npm http GET https://registry.npmjs.org/karma 
npm http 304 https://registry.npmjs.org/grunt-contrib-clean/0.5.0 
npm http 304 https://registry.npmjs.org/grunt-contrib-stylus/0.10.0 
npm http 304 https://registry.npmjs.org/grunt-contrib-uglify/0.2.7 
npm http 304 https://registry.npmjs.org/grunt-contrib-jshint/0.7.2 
npm http 304 https://registry.npmjs.org/grunt-karma 
npm http 304 https://registry.npmjs.org/karma-jasmine 
npm http 304 https://registry.npmjs.org/karma-phantomjs-launcher 
npm http 304 https://registry.npmjs.org/karma-chrome-launcher 
npm http 304 https://registry.npmjs.org/grunt 
npm http 304 https://registry.npmjs.org/karma 
npm ERR! Error: No version provided 
npm ERR!  at needVersion (/usr/local/lib/node_modules/npm/lib/cache.js:1238:40) 
npm ERR!  at /usr/local/lib/node_modules/npm/lib/cache.js:1112:10 
npm ERR!  at process._tickCallback (node.js:415:13) 
npm ERR! If you need help, you may report this log at: 
npm ERR!  <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR!  <[email protected]> 

npm ERR! System Darwin 13.1.0 
npm ERR! command "node" "/usr/local/bin/npm" "install" 
npm ERR! cwd /Users/jzaun/Development/jzAddons 
npm ERR! node -v v0.10.18 
npm ERR! npm -v 1.3.8 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /Users/jzaun/Development/jzAddons/npm-debug.log 
npm ERR! not ok code 0 

我如何角來進行測試?

有什麼辦法可以使用grunt來安裝某些形式的窗臺而不必製作bower.json嗎?我真的不想處理2套裝系統: - /我不需要Angular來測試任何東西,而且看起來很愚蠢,必須經歷所有的環節......

回答

0

不確定它是否對您有幫助但這裏是我所擁有的:

我用Yeoman來支撐角發生器的角度應用。 它設置了你需要的一切,包括業力和一些樣本測試。 然後,您可以與您的應用程序進行比較,看看您錯過了什麼。

在我的package.json我有關於因果報應這些條目:

"karma-ng-scenario": "~0.1.0", 
"grunt-karma": "~0.6.2", 
"karma-script-launcher": "~0.1.0", 
"karma-firefox-launcher": "~0.1.3", 
"karma-chrome-launcher": "~0.1.2", 
"karma-html2js-preprocessor": "~0.1.0", 
"karma-jasmine": "~0.1.5", 
"karma-coffee-preprocessor": "~0.1.3", 
"karma-requirejs": "~0.2.1", 
"karma-phantomjs-launcher": "~0.1.2", 
"karma": "~0.10.9", 
"karma-ng-html2js-preprocessor": "~0.1.0" 

你看到有版本號無處不在,而你有一個「*」。

,在我Karma.conf.js文件我引用角:

files: [ 
    'app/bower_components/angular/angular.js', 
    'app/bower_components/angular-mocks/angular-mocks.js', 
    'app/bower_components/angular-resource/angular-resource.js', 
    'app/bower_components/angular-cookies/angular-cookies.js', 
    'app/bower_components/angular-sanitize/angular-sanitize.js', 
    'app/bower_components/angular-route/angular-route.js', 
    'app/scripts/*.js', 
    'app/scripts/**/*.js', 
    'test/mock/**/*.js', 
    'test/spec/**/*.js' 
], 

希望這有助於以某種方式。 讓我知道如果你需要更多的信息

+0

我從來沒有使用'「*」'但根據[這個問題](http://stackoverflow.com/questions/16073603/how-do-i-update-each - 依賴於包的JSON到最新版本),它應該工作。有沒有突然的變化? – glepretre

+0

問題是我無法獲得npm安裝角度。看起來我不得不使用涼亭除了npm。 PITA。 – Justin808

+1

犯錯。對不起,我可能會誤解你,但在npm中,你可以安裝節點包,比如yo或generator-angular。鮑爾是另一回事。它管理你的web應用程序的JavaScript依賴關係。所以angular.js或jquery或bootstrap.css是bower需要處理的事情。而使用npm安裝諸如karma,grunt,yeoman等nodejs模塊。請參閱:http://stackoverflow.com/questions/18641899/difference-between-bower-and-npm – PeterFromCologne