yeoman / generator-angular

Yeoman generator for AngularJS
http://yeoman.io
5.73k stars 1.44k forks source link

"grunt test" throws "karma.conf.js does not exist" #1283

Open miparnisari opened 8 years ago

miparnisari commented 8 years ago

I'm using angular generator version 0.15.1. These packages, among others, are in my package.json:

{
  "devDependencies": {
    "grunt-karma": "^0.12.1",
    "jasmine-core": "^2.4.1",
    "karma": "^0.13.21",
    "karma-chrome-launcher": "^0.2.2",
    "karma-jasmine": "^0.3.7",
    "karma-phantomjs-launcher": "^1.0.0",
    "phantomjs-prebuilt": "^2.1.4"
  }
}

I have no karma.conf.js file in the test folder nor anywhere else.

When I run grunt test, I get

Running "karma:unit" (karma) task
26 02 2016 20:58:22.744:ERROR [config]: File C:\Users\miparnisari\Desktop\app\test\karma.conf.js does not exist!
eddiemonge commented 8 years ago

What version of generator-karma do you have?

miparnisari commented 8 years ago

I've no idea, how do I check?

eddiemonge commented 8 years ago

npm info -g generator-karma | grep 'version:'

miparnisari commented 8 years ago

2.0.0

eddiemonge commented 8 years ago

Try running yo karma

miparnisari commented 8 years ago

I get the following error now:

Running "connect:test" (connect) task
Verifying property connect.test exists in config...OK
File: [no files]
Options: protocol="http", port=9001, hostname="localhost", base=".", directory=null, keepalive=false, debug=false, livereload=35729, open=false, useAvailablePort=false, onCreateServer=null, middleware=undefined
Started connect web server on http://localhost:9001

Loading "grunt-karma" plugin

Registering "C:\Users\miparnisari\Desktop\vinti-landing\node_modules\grunt-karma\tasks" tasks.
Loading "grunt-karma.js" tasks...OK
+ karma

Running "karma" task

Running "karma:unit" (karma) task
Verifying property karma.unit exists in config...OK
File: [no files]
Options: background=false, client={}
04 03 2016 18:19:41.993:INFO [karma]: Karma v0.13.21 server started at http://localhost:8082/
04 03 2016 18:19:42.005:INFO [launcher]: Starting browser PhantomJS
04 03 2016 18:19:43.596:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#JIoiBKHlUW4GuXvWAAAA with id 89298213
PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
Warning: Task "karma:unit" failed. Use --force to continue.

Aborted due to warnings.
eddiemonge commented 8 years ago

It sounds like generator-karma didnt run initially when you did the generator so the files aren't setup correctly. Take a look at https://github.com/yeoman/generator-angular/blob/master/app/index.js#L99 and add those to your karma file and it should be good

miparnisari commented 8 years ago

Oops accidentally closed this issue. I think I did not follow the setup steps properly, I'll try again. I still don't understand how or why generators depend on each other.

bumprat commented 8 years ago

path.karma is not defined correctly, you need something like this in your gulpfile.js: note: assuming angular-ui-sortable, angular-local-storage installed

var paths = {
  scripts: [yeoman.app + '/scripts/**/*.js'],
  styles: [yeoman.app + '/styles/**/*.scss'],
  test: ['test/spec/**/*.js'],
  testRequire: [
    'bower_components/angular/angular.js',
    'bower_components/angular-mocks/angular-mocks.js',
    'bower_components/angular-resource/angular-resource.js',
    'bower_components/angular-cookies/angular-cookies.js',
    'bower_components/angular-sanitize/angular-sanitize.js',
    'bower_components/angular-route/angular-route.js',
    'bower_components/angular-animate/angular-animate.js',
    'bower_components/angular-touch/angular-touch.js',
    'bower_components/angular-ui-sortable/sortable.js',
    'bower_components/angular-local-storage/dist/angular-local-storage.js',
    'test/mock/**/*.js',
    'test/spec/**/*.js'
  ],
  karma: 'test/karma.conf.js',
  views: {
    main: yeoman.app + '/index.html',
    files: [yeoman.app + '/views/**/*.html']
  }
};