Jasmine addiction

I am really new to javascript and I am writing some jasmine tests in a simple javascript spec. How can I imagine jquery dependencies and underscores in this specification without using requireJS.?

describe( "Testing Karma and Jasmine", function () {

    describe("Hello world test", function() {
        it("says hello", function() {
            expect(testingJasmine()).toEqual("Hello world!");
        });
    });

});

describe('just checking', function() {

    it('works for app', function() {
        var el = $('<div></div>');

        var app = restify.createServer()
        app.render();

        expect(el.text()).toEqual('require.js up and running');
    });

    it('works for underscore', function() {
        // just checking that _ works
        expect(_.size([1,2,3])).toEqual(3);
    });

});

If you look at the attached code, it will not be able to resolve the dependencies of $ (JQUERY) and _ (UNDERSCORE).

+4
source share
2 answers

You must add the path to the files in the karma configuration file .

You can add dependencies like this

files = [
  JASMINE,
  JASMINE_ADAPTER,
  'scripts/libs/jquery.js,
  'scripts/libs/underscore.js
];

Check this sample configuration file ,

+4
source

, :

/// <reference path="../js/libs/jquery-2.0.3.min.js" />

, , . JS _references.js JS. _references.js .

/// <reference path="_references.js" />
+1

All Articles