How to start jasmine tests with grunt?

1.6k views Asked by At

I want to create a grunt task for running jasmine tests automatically when the code changed. For AMD support I installed grunt-template-jasmine-requirejs. I added these lines to my gruntfile:

connect: {
    test : {
        port : 8000
    }
},

jasmine: {
    jasmine_tests: {
        src: 'src/**/*.js',
        options: {
            specs: 'spec/*Spec.js',
            helpers: 'spec/*Helper.js',
            host: 'http://127.0.0.1:8000/',
            template: require('grunt-template-jasmine-requirejs'),
            templateOptions: {
                requireConfigFile: 'public/js/app/config/config.js'
            }
        }
    }
},

Now I try to start my tests by typing grunt jasmine. But all I get is this:

Running "jasmine:jasmine_tests" (jasmine) task

Testing jasmine specs via PhantomJS

Warning: PhantomJS failed to load your page. Use --force to continue.

Aborted due to warnings.

What could be wrong there?

My directory structure:

- website3
    - .grunt
        + grunt-contrib-jasmine
    + node_modules
    - public
        - js
            - app
                + collections
                - config
                    > config.js
                + ...
                - views
                    + ...
                    > AddVehicleView.js
                    > ...
        + libs
        > index.html
    + server
    - spec
        + helpers
        - support
            > jasmine.json
        > AddVehicleViewSpec.js
    > .bowerrc
    > ...
    > _SpecRunner.html
    > Gruntfile.js
    > package.json
1

There are 1 answers

0
Yazan Rawashdeh On

you have to do grunt connect to serve your files first and then in another terminal tab do grunt jasmine , that's all.