简体   繁体   中英

How to start jasmine tests with grunt?

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

您必须先做grunt connect来提供文件,然后在另一个终端选项卡中做grunt jasmine ,仅此grunt jasmine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM