Hi,
I'm new AngularJS and Mocha.
I'm trying to get a Mocha test working on AngularJS call.
I know Sinon can stub jQuery ajax call like
sinon.stub(jQuery, 'ajax') etc.
Can I do simlar for AngularJS $http.GET?
Or do I have to use sinon server? I tried sinon server, doesn't work like this:
before(function() {
...... inject my module to be test
server = sinon.fakeServer.create();
});
it("mock ajax return data", function () {
var controller = createController();
...call my function (no parameter)
// This is part of the FakeXMLHttpRequest API
server.requests[0].respond(
200,
{ "Content-Type": "application/json" },
JSON.stringify([jobJSON])
);
expect(....
I have a HTML fixture for Mocha test, but it stopped when I try with nock, like
var nock=require('nock');
Thanks a lot.