How to make jasmine ajax work with crap jasmine

I am trying to use the jasmine-ajax library to mock an ajax request with grunt-contrib-jasmine , but it seems that jasmine cannot find the library (it says jasmine.Ajax is undefined).

my grunt file:

   jasmine: {
            test:{
                src :[ '<%= watch.files %>'],
                options: {
                    vendor: 'vendor/mock-ajax.js',
                    specs : ['specs/**/*spec.js'],
                    helpers : 'specs/helpers/*.js',
                    timeout : 10000
                }
            }

I downloaded mock-ajax.js and placed it in the provider folder. this is the part of the test where the error appears:

  beforeEach(function() {
            jasmine.Ajax.install();
        });
+4
source share
2 answers

.. : https://github.com/pivotal/jasmine-ajax/blob/master/lib/mock-ajax.js . jasmine-ajax npm, mock-ajax.js grunt: : ['node_modules/jasmine-ajax/lib/mock-ajax.js'],

jsoverson (https://github.com/gruntjs/grunt-contrib-jasmine/issues/111#issuecomment-51806488)

+3

, "git clone", "npm install", "grunt test", ! , :

  jasmine: {
      test:{
        src :[
          '<%= watch.files %>'
        ],
        options: {
          vendor: ['node_modules/jasmine-ajax/lib/mock-ajax.js',
                   'node_modules/jquery/dist/jquery.js',
                   'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
                   'node_modules/handlebars/dist/handlebars.js',
                  ],
          specs : ['spec/helpers/*.js',
                   'spec/**/*spec.js'],
          helpers : ['spec/helpers/*.js'],
          timeout : 10000,
          keepRunner: true
        }
      },
0

All Articles