Where can I put HTML tools when I use JsTestDriver?

I am having difficulty uploading a JSTD file to an HTML file.

My directory structure:

localhost/JsTestDriver.conf localhost/JsTestDriver.jar localhost/js/App.js localhost/js/App.test.js localhost/fixtures/index.html 

My conf file says:

 server: http://localhost:4224 serve: - fixtures/*.html load: - http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js - jasmine/lib/jasmine-1.1.0/jasmine.js - jasmine/jasmine-jquery-1.3.1.js - jasmine/jasmine-jstd.js - js/App.js test: - js/App.test.js 

My test:

 describe("App", function(){ beforeEach(function(){ jasmine.getFixtures().fixturesPath = 'fixtures'; loadFixtures('index.html'); **//THIS LINE CAUSES IT TO FAIL** }); describe("When App is loaded", function(){ it('should have a window object', function(){ expect(window).not.toBe(null); }); }); }); 

And my console output:

enter image description here

( link to full size image )

I considered this question , but it did not help me figure it out. Strange when i comment

loadFixtures ('index.html');

the test passes.

Any ideas?

+4
source share
2 answers

Ok, got it. JsTestDriver adds a β€œtest” to the path to your fixtures.

In addition, jasmine-jquery gets attributes using ajax.

So these steps finally helped me:

In jsTestDriver.conf:

 serve: - trunk/wwwroot/fixtures/*.html load: - trunk/wwwroot/js/libs/jquery-1.7.1.min.js - jstd/jasmine/standalone-1.2.0/lib/jasmine-1.2.0/jasmine.js - jstd/jasmine-jstd-adapter/src/JasmineAdapter.js - jstd/jasmine-jquery/lib/jasmine-jquery.js - trunk/wwwroot/js/main.js test: - trunk/wwwroot/js/main.test.js 

In my test file:

 describe("main", function(){ beforeEach(function(){ jasmine.getFixtures().fixturesPath = '/test/trunk/wwwroot/fixtures'; jasmine.getFixtures().load('main.html'); }); describe("when main.js is loaded", function(){ it('should have a div', function(){ expect($('div').length).toBe(1); }); }); }); 

Note that the beforeEach() call uses an absolute URL for the HTML device.

+2
source

Try changing the device path:

 jasmine.getFixtures().fixturesPath = '/fixtures'; 

I get different but similar weird errors otherwise.

0
source

Source: https://habr.com/ru/post/1390931/


All Articles