New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support window.fetch #134

Open
onlywei opened this Issue Sep 30, 2015 · 8 comments

Comments

Projects
None yet
6 participants
@onlywei

onlywei commented Sep 30, 2015

This is the new standard for the web, replacing(?) XHR. Are there plans to support it?

@slackersoft

This comment has been minimized.

Show comment
Hide comment
@slackersoft

slackersoft Oct 1, 2015

Member

According to MDN, this is still experimental and the official API hasn't been locked down yet, so we don't have a plan for support just yet. Once it is made official, I'd be happy to review a pull request that added support for the new interface.

Member

slackersoft commented Oct 1, 2015

According to MDN, this is still experimental and the official API hasn't been locked down yet, so we don't have a plan for support just yet. Once it is made official, I'd be happy to review a pull request that added support for the new interface.

@lencioni

This comment has been minimized.

Show comment
Hide comment
@lencioni

lencioni Dec 1, 2015

Contributor

Once it is made official

It looks like some things that seem relatively stable (to me at least) are still listed as experimental--for example, CSS transform. Granted, it looks like the whatwg-fetch repo is recently quite active but if the plan is to wait until MDN doesn't list it as experimental, we might be waiting for quite a while. ;) Perhaps @annevk can give us some insight on how stable the API is and if we can proceed with more confidence?

Contributor

lencioni commented Dec 1, 2015

Once it is made official

It looks like some things that seem relatively stable (to me at least) are still listed as experimental--for example, CSS transform. Granted, it looks like the whatwg-fetch repo is recently quite active but if the plan is to wait until MDN doesn't list it as experimental, we might be waiting for quite a while. ;) Perhaps @annevk can give us some insight on how stable the API is and if we can proceed with more confidence?

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Dec 7, 2015

fetch() is pretty stable and implemented by several browsers now.

annevk commented Dec 7, 2015

fetch() is pretty stable and implemented by several browsers now.

@slackersoft

This comment has been minimized.

Show comment
Hide comment
@slackersoft

slackersoft Jan 6, 2016

Member

Sounds good. I'd be happy to review a pull request that supports fetch only in browsers that provide the functionality, leaving browsers that don't (IE, Safari) to behave as if no mock was applied.

Member

slackersoft commented Jan 6, 2016

Sounds good. I'd be happy to review a pull request that supports fetch only in browsers that provide the functionality, leaving browsers that don't (IE, Safari) to behave as if no mock was applied.

@jaredrada

This comment has been minimized.

Show comment
Hide comment
@jaredrada

jaredrada Dec 21, 2016

would love to see support for the fetch api 👍

jaredrada commented Dec 21, 2016

would love to see support for the fetch api 👍

@codingthat

This comment has been minimized.

Show comment
Hide comment
@codingthat

codingthat Apr 22, 2017

Just wondering what I'm missing here. I have Jasmine 2.5.3 and Jasmine-Ajax 3.3.1, and the following seems to run fine (and break fine, if I mess with it):

describe("real ajax", function() {
    var testJson = {
        "one": "two",
        "key": "value"
    };

    it("can use fetch too", function (done) {
        var doneFn = jasmine.createSpy("success");
        fetch("http://echo.jsontest.com/key/value/one/two").then(function(response) {
            expect(response.status).toBe(200);
            return response.json(); // returns a promise
        }).then(function(returnedValue) {
            // won't be the same object reference, so we can stringify to compare:
            expect(JSON.stringify(returnedValue)).toBe(JSON.stringify(testJson));
            // or we can use our spy, because toHaveBeenCalledWith is more forgiving
            doneFn(returnedValue);
            expect(doneFn).toHaveBeenCalledWith(testJson);
            // either way, we need to call done(), otherwise our test will time out
            done();
        }).catch(function(err) {
            // Error :(
        });
    });
});

codingthat commented Apr 22, 2017

Just wondering what I'm missing here. I have Jasmine 2.5.3 and Jasmine-Ajax 3.3.1, and the following seems to run fine (and break fine, if I mess with it):

describe("real ajax", function() {
    var testJson = {
        "one": "two",
        "key": "value"
    };

    it("can use fetch too", function (done) {
        var doneFn = jasmine.createSpy("success");
        fetch("http://echo.jsontest.com/key/value/one/two").then(function(response) {
            expect(response.status).toBe(200);
            return response.json(); // returns a promise
        }).then(function(returnedValue) {
            // won't be the same object reference, so we can stringify to compare:
            expect(JSON.stringify(returnedValue)).toBe(JSON.stringify(testJson));
            // or we can use our spy, because toHaveBeenCalledWith is more forgiving
            doneFn(returnedValue);
            expect(doneFn).toHaveBeenCalledWith(testJson);
            // either way, we need to call done(), otherwise our test will time out
            done();
        }).catch(function(err) {
            // Error :(
        });
    });
});
@slackersoft

This comment has been minimized.

Show comment
Hide comment
@slackersoft

slackersoft Apr 24, 2017

Member

@codingthat it looks like you're not mocking AJAX at all and thus not actually using the functionality that is being discussed here. The Jasmine-Ajax library is meant to mock out calls to external APIs so the real call doesn't happen.

Member

slackersoft commented Apr 24, 2017

@codingthat it looks like you're not mocking AJAX at all and thus not actually using the functionality that is being discussed here. The Jasmine-Ajax library is meant to mock out calls to external APIs so the real call doesn't happen.

@codingthat

This comment has been minimized.

Show comment
Hide comment
@codingthat

codingthat Apr 25, 2017

@slackersoft Thanks, and sorry for the intrusion. Not long after that I had realized the distinction, but had a few other things happening and forgot to return to this thread.

codingthat commented Apr 25, 2017

@slackersoft Thanks, and sorry for the intrusion. Not long after that I had realized the distinction, but had a few other things happening and forgot to return to this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment