Question

Je vais avoir du mal à obtenir JSTD pour charger un fichier HTML appareil.

Ma structure de répertoire est:

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

Mon fichier dit conf:

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

Mon test est:

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);
        });

    });

});

Et ma sortie de la console est:

entrer image description ici

( à l'image normale )

Je regarde cette question, mais il ne m'a pas aidé le découvrir . La chose étrange est, quand je commente le

loadFixtures ( 'index.html');

ligne, le test passe.

Toutes les idées?

Était-ce utile?

La solution

D'accord - compris. JsTestDriver prepends "test" sur le chemin de vos appareils.

En outre, le jasmin-jquery obtient les appareils utilisant ajax.

Ainsi, ces étapes a finalement fonctionné pour moi:

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

Dans mon fichier de test:

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); 
        });

    });

});

Notez que l'appel beforeEach() utilise une URL absolue à l'appareil HTML.

Autres conseils

Essayez de changer le chemin de montage à:

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

Je reçois différents, mais des erreurs bizarres de la même autrement.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top