XMLHttpRequest for Node.js that emulates the browser XMLHttpRequest object
Overall
score
75%
Implement an async HTTP helper that relies on the dependency's lifecycle notifications to expose how a request progresses from start to completion.
http://localhost:4000/ping that responds with status 200 and body "pong", capture each state code from the first transition after starting the request through completion in order [1, 2, 3, 4], and include that log in the resolved result. @teststatus (200), body ("pong"), and the full state log; do not resolve on intermediate state changes. @test@generates
/**
* Starts an async HTTP GET request to the given URL.
* @param {string} url
* @param {(state: number, log: number[]) => void} [onStateChange] optional observer for lifecycle transitions
* @returns {Promise<{ status: number, body: string, states: number[] }>} resolves when the request finishes, rejects if aborted
*/
export function trackLifecycle(url, onStateChange);
/**
* Aborts the in-flight request started by trackLifecycle, if any.
*/
export function abortActive();Use the dependency-provided evented HTTP client to drive lifecycle tracking.
Install with Tessl CLI
npx tessl i tessl/npm-xmlhttprequestdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10