lundi 29 février 2016

Load Json Fixture in Karma/Mocha

I am using Karma with Mocha and karma-fixture. If I go into debug when I run tests, I can see the file is loaded in the server. If I changed the config included:true, then I can see it's loaded on the console. The extension is changed to .js (rather than .json) and if I view source on the file (in browser window) the json is wrapped in a function -- so it seems like everything is happening as described in the documentation. However, I get an error that the file cannot be found. I have included the relevant configs and errors below. Thank you!

The configuration:

The file is located here, pathed from root of my project: \test\fixtures\json-data\querybrowser.json

Karma

 files: [{pattern: 'test/fixtures/{,*/}*', watched: true, included: false, served: true}]

TEST spec

 fixture.setBase('base/test/fixtures/json-data');
 querybrowser_json = fixture.load('querybrowser.json');

The Error

 Chrome 48.0.2564 (Windows 7 0.0.0) Query Browser Function Tests "before all" hook FAILED
 ReferenceError: Cannot find fixture 'base/test/fixtures/json-data/querybrowser.js' 
 at Fixture._throwNoFixture (////node_modules/karma-fixture/lib/fixture.js:141:13)

Aucun commentaire:

Enregistrer un commentaire