Loading a mock JSON file within Karma+AngularJS test

前端 未结 8 1547
星月不相逢
星月不相逢 2020-11-28 18:57

I have an AngularJS app set up with tests using Karma+Jasmine. I have a function I want to test that takes a large JSON object, converts it to a format that\'s more consumab

8条回答
  •  攒了一身酷
    2020-11-28 19:12

    There are Karma preprocessors that work with JSON files also. There is one here:

    https://www.npmjs.org/package/karma-ng-json2js-preprocessor

    And shameless plug, this is one I developed that has RequireJS support

    https://www.npmjs.org/package/karma-ng-json2js-preprocessor-requirejs

提交回复
热议问题