Closed smoebody closed 2 days ago
An easy workaround is to do
const agent = new Agent();
agent.isMockActive = true
Is this a bug or is expected @KhafraDev?
Ignore my previous answer, fetch's dispatcher
option takes precedence over the global dispatcher.
await fetch("http://localhost/test", {
dispatcher: agent,
method: "POST",
body: "test",
});
The dispatcher has to be mockAgent
in this case, or the option has to be unset, in which case it'll fallback to the global dispatcher (being mockAgent).
Bug Description
When setting a custom agent as option for
MockAgent
thebody
property is of typeasyncGenerator
and therefore never matches my source bodyReproducible By
A minimal example follows
The output is
Expected Behavior
The output should be
when removing the
dispatcher
property from thefetch
call it works as intended (i guess, althoughtest
is printed twice)Environment
Docker-Image: node:22-alpine Kernel: 6.11.8-300.fc41.x86_64 x86_64 Linux Node: v22.11.0 undici: 6.21.0