I'm having a hard time getting JSTD to load a fixture HTML file.
My directory structure is:
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 is:
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 is:
I looked at this question but it didn't help me figure it out. The weird thing is, when I comment out the
loadFixtures('index.html');
line, the test passes.
Any ideas?
Okay -- figured it out. JsTestDriver prepends "test" to the path to your fixtures.
Also, jasmine-jquery gets fixtures using ajax.
Thus, these steps finally worked for me:
In jsTestDriver.conf:
In my test file:
Note that the
beforeEach()
call uses an absolute URL to the HTML fixture.