¿Dónde pongo accesorios HTML cuando estoy usando Jstestdriver?
-
28-10-2019 - |
Pregunta
Me está costando hacer que JSTD cargue un archivo HTML fijo.
La estructura de mi directorio es:
localhost/JsTestDriver.conf
localhost/JsTestDriver.jar
localhost/js/App.js
localhost/js/App.test.js
localhost/fixtures/index.html
Mi archivo conf dice:
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
Mi prueba es:
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);
});
});
});
Y la salida de mi consola es:
(Enlace a una imagen de tamaño completo)
Miré esta pregunta Pero no me ayudó a resolverlo. Lo extraño es que cuando comento el
loadFixtures ('index.html');
Línea, la prueba pasa.
¿Algunas ideas?
Solución
Bien, lo descubrí. Jstestdriver preputa "prueba" en el camino a sus accesorios.
Además, Jasmine-Jquery obtiene accesorios usando AJAX.
Por lo tanto, estos pasos finalmente me funcionaron:
En 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
En mi archivo de prueba:
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);
});
});
});
Tenga en cuenta que el beforeEach()
Call utiliza una URL absoluta al accesorio HTML.
Otros consejos
Intente cambiar el camino del accesorio a:
jasmine.getFixtures().fixturesPath = '/fixtures';
Obtigo errores diferentes, pero similares, de lo contrario.