I am developing a web frontend using Polymer. I have a webcomponent which uses other webcomponents, for example a paper-input or some custom webcomponents. For demo purposes i am using the sinon fake xhr server to mock some elasticsearch requests, which is really nice for testing. In the webcomponents i use the polymer appLocalizeBehavior to load some locales from a json file. AppLocalizeBehavior uses iron-request to load the files via an url. I configured sinon to filter and exclude all urls including "locales.json", like this:
this._server = sinon.fakeServer.create();
this._server.autoRespond = true;
this._server.xhr.useFilters = true;
this._server.xhr.addFilter(function(method, url) {
return url.includes("locales.json");
});
If i disable the xhr fake server the locales from all components are loading correctly. But if i enable sinon it seems like the locales are beeing loaded but sinon somehow returns them with a wrong encoding.
Someone out there facing similar problems?
There is a pull request in pending to resolve this issue: https://github.com/sinonjs/nise/pull/45
If you want to solve it locally, then in your sinon.js file, from your bower_components folder, you have to replace this line of code:
copyAttrs(["responseText", "response"]);
with this one:
copyAttrs(["responseText", "response", "responseType"]);