Giter Club home page Giter Club logo

Comments (9)

beckend avatar beckend commented on May 26, 2024 1

the tests looks convincing, makes me wonder if i did something weird, will get back to this coming days.

from xhr-mock.

jameslnewell avatar jameslnewell commented on May 26, 2024

Which version are you using? Are you using xhr-mock@next (v2)? Can you please provide a snippet of a minimal example that you'd expect to work.

from xhr-mock.

beckend avatar beckend commented on May 26, 2024
const xhr = new XMLHttpRequest();

const handleProgress = (evt) => {
    console.log(evt);
};

xhr.upload.addEventListener('progress', handleProgress);
xhr.upload.removeEventListener('progress', handleProgress);

using 2.x preview 7

from xhr-mock.

beckend avatar beckend commented on May 26, 2024

also on the note with this snippet which does not work in xhr-mock, but does in browsers.

xhr.addEventListener('loadend', handleLoadEnd);

if error occurs, this does not fire(it should).

from xhr-mock.

jameslnewell avatar jameslnewell commented on May 26, 2024

Sorry, can you please include a full example including the mock setup and full xhr details.

It should work according to these tests

from xhr-mock.

jameslnewell avatar jameslnewell commented on May 26, 2024

Hi @beckend. Have you managed to figure out whats going wrong?

from xhr-mock.

beckend avatar beckend commented on May 26, 2024

@jameslnewell sorry it took a while.
https://github.com/beckend/xhr-mock/blob/xhr_debug/test/debug.test.ts
You can clone the branch and test, the fetchXHR is used in production and is working intended in a webrowser.

The tests should pass but do not, it's the problem i have described in this thread.

from xhr-mock.

jameslnewell avatar jameslnewell commented on May 26, 2024

Sorry I've taken so long to respond! I had some time on the train to investigate this today - thanks for your detailed repo!

xhr-mock wasn't emitting upload progress events because you were using an empty string for the body and it was evaluating to false. I've fixed the issue and released [email protected]. https://github.com/jameslnewell/xhr-mock/blob/master/src/MockXMLHttpRequest.ts#L221

re the loadend event, I think it depends on what type of error occurred. Is that your understanding too? https://xhr.spec.whatwg.org/#request-error-steps

Currently only one type of error handling is implemented and we don't have a way to tell xhr-mock which type of error handling to execute. What do you think of something like:

import mock, {RequestError, ResponseError, EndOfBodyError} from 'xhr-mock';

mock.get('/', () => Promise.reject(new ResponseError()));

from xhr-mock.

beckend avatar beckend commented on May 26, 2024

looks fine to me, xhr was never easy to mock to begin with

from xhr-mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.