0

I am writing unit test case for node code and i need to compare dummy object with the actual result .

For comparing that i wrote some dummy json data in a file and i end up getting error You may need to load appropraite loaders to handle this file type

Code:

it('comparing structures',()=>{
    var result = instance.parseResponse(input,esResponse);
    assert.deepEqual( result, expectedJSON, "Two objects can be the same in value" );
});

Json:

var expectedJSON ={
DateMetric {
    aggregate: Aggregate {
        total: 0,
        average: null,
        count: 0,
        min: null,
        max: null
    },
    startDate: Fri Apr 01 2016 05: 30: 00 GMT + 0530(India Standard Time),
    weeks: []
}}

I have no idea what this error is all about

I have karma set up and i am writing test cases using mocha and chai

Any help would be appreciated.

Shikha thakur
  • 1,269
  • 13
  • 34
  • If you print `result` and `expectedJSON`, do you get the right JSON? Do you know if the error is thrown at `instance.parseResponse` or by `assert`? – DrakaSAN Sep 30 '16 at 09:38
  • @DrakaSAN I have already written test cases to check if they are any errors thrown at instance.parseResponse and it was success – Shikha thakur Sep 30 '16 at 09:44
  • Are you using Babel at the same time as WebPack? There seems to be a lot of result when searching for that error code. [example](http://stackoverflow.com/questions/33469929/you-may-need-an-appropriate-loader-to-handle-this-file-type-with-webpack-and-b) – DrakaSAN Sep 30 '16 at 09:52
  • I am using webpack but not babel – Shikha thakur Sep 30 '16 at 09:53
  • Did you import `json-loader`? [Seems to be a common error too](https://github.com/webpack/webpack/issues/965) – DrakaSAN Sep 30 '16 at 09:55
  • no i havent imported it – Shikha thakur Sep 30 '16 at 09:56
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124629/discussion-between-shikha-thakur-and-drakasan). – Shikha thakur Sep 30 '16 at 09:56

1 Answers1

1

My guess is that you have to import json-loader in webpack, which seems to be a common error seeing all the googme search results.

DrakaSAN
  • 7,673
  • 7
  • 52
  • 94