2

我正在尝试编写一些单元测试。我收到关于角度未定义的错误,所以我想我需要将角度 js 文件包含在我的其他 js 文件中......为此,我正在尝试 npm 安装它......

{
  "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 jzAddons@0.0.1 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!     <npm-@googlegroups.com>

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 安装一些东西而不必制作 bower.json?我真的不想处理 2 个包系统:-/ 除了测试,我不需要 Angular 来做任何事情,而且必须经历所有的圈子似乎很愚蠢......

4

1 回答 1

0

不确定它是否对您有帮助,但这是我所拥有的:

我使用Yeoman用它的 generator-angular 搭建了一个 angular 应用程序。它设置了您需要的一切,包括业力和一些示例测试。然后您可以与您的应用程序进行比较,看看您缺少什么。

在我的 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 文件中,我引用了 angular:

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'
],

希望这会有所帮助。如果您需要更多信息,请告诉我

于 2014-03-26T07:44:41.483 回答