Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major Trouble Making this Operational - Example Repo possible? #2

Closed
netpoetica opened this issue Feb 3, 2013 · 4 comments
Closed

Comments

@netpoetica
Copy link

Is there any possibility, when you have some time, that you could get put together a bare bones example like https://github.com/jsoverson/grunt-contrib-jasmine-example ?

I can get Jasmine working, I can get grunt working, but as soon as I throw require into the mix it's just error after error after error. I think there are a lot of discrepencies between where the Gruntfile.js file lives and where my actual public/js/*.js source code lives, and how the requireConfig needs to handle different path resolution.

It would be extra helpful if it were in the context of an MVC framework, for example, a directory structure like:

/ - package.json
  - app.js
  - Gruntfile.js
  - specs / - models / - racecar.spec.js, driver.spec.js
  - public / - js / - models / - racecar.js, driver.js
                           - views
                           - libs (isn't this where require.js, jquery.min.js, underscore, backbone etc would go?)
                  - css
                  - templates
@jsoverson
Copy link
Collaborator

The repo itself is a self-running example of grunt-contrib-jasmine and this template.

To aid in troubleshooting you can build the specrunner and open it in a browser, eg if your task is named "jasmineTest", run grunt jasmine:jasmineTest:build and a _SpecRunner.html file will be generated in your project's root.

It may be worthwhile to fork this repo and configure a template that suits your setup better. Requirejs configurations vary drastically from project to project and the more configuration you have the more custom your setup will need to be.

@netpoetica
Copy link
Author

Okay, giving this a shot. It would definitely be helpful to see what order this lib is loading my scripts in and if it is finding them. I'm not sure where your "jasmineTest" is coming from though. I added a task called jasmineTest and linked it to ['jasmine'], but grunt doesn't like it:

  grunt-contrib-jasmine-example git:(master)  grunt jasmine:jasmineTest:build
Running "jasmine:jasmineTest:build" (jasmine) task
Verifying property jasmine.jasmineTest exists in config...ERROR
>> Unable to process task.
Warning: Required config property "jasmine.jasmineTest" missing. Use --force to continue.

Aborted due to warnings.

So instead I removed the task and tried:

grunt jasmine:build

but no _SpecRunner.html was generated. Here is my Gruntfile.js if there's anything maybe you could flag as me being a durp:

module.exports = function(grunt) {
  'use strict';

  // Project configuration.
  grunt.initConfig({
    meta : {
      src   : 'public/**/*.js',
      specs : 'spec/**/*.js'
    },
    watch: {
      test : {
        files: ['<%= meta.src %>','<%= meta.specs %>'],
        tasks: 'test'
      }
    },
    jasmine : {
      src : '<%= meta.src %>',
      options : {
        template: require('grunt-template-jasmine-requirejs'),
        specs : '<%= meta.specs %>',
        templateOptions: {
            requireConfig: {
                paths: {
                    Backbone: '/js/libs/backbone',
                    jQuery: '/js/libs/jquery',
                    Underscore: '/js/libs/underscore'
                },
                shim: {
                    'Backbone': ['Underscore', 'jQuery']
                }
            }
        }
      }
    },
    jshint: {
      all: [
        'Gruntfile.js',
        '<%= meta.src %>',
        '<%= meta.specs %>'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('jasmineTest', ['jasmine']);

  grunt.registerTask('test', ['jshint', 'jasmine']);

  // Default task.
  grunt.registerTask('default', ['test']);

};

@jsoverson
Copy link
Collaborator

I see you've opened and closed other repos related to grunt and the grunt 0.4.0 changes. Let me know if you still have issues configuring jasmine with the template.

@jsoverson
Copy link
Collaborator

Closing, let me know if there are further problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants