Chris
Chris

Reputation: 189

How to use real AJAX calls with Visual Studio, Chutzpah and Jasmine

I create some Jasmine test and want to run the test with the Visual Studio Test-Explorer and the Chutzpah Plugin. For some tests I need a real AJAX call, so I think it is not an option to fake the call. (jasmine ajax mock plugin)

This simple test run without problem in the browser:

it("Ajax get", function (done) {
    var a = 0;

    $.get("https://myurl.net/dummy.json").always(function (result) {
        console.log(result);
        a = 1;
        expect(a).toEqual(1);
        done();
    });
});

But if I run the Test in Visual Studio (Text-Explorer and/or Chutzpah context menu) there is a timeout for the Ajax get.

How can I fix it or have I some other option to run the test with Visual Studio? (In the future I want to add the JS Test to my Gated Checkin)

Upvotes: 0

Views: 234

Answers (1)

Chris
Chris

Reputation: 189

I have tried a lot but nothing works in each scenario. Because that I added a much more complex stub with the jasmine ajax mock plugin. Not the searched fix but it works standalone, browser, console and VS Test Explorer.

Upvotes: 0

Related Questions