2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

fix(fetch): use current global fetch instead of cached one when env fetch is not specified to keep MSW support; (#7030)

This commit is contained in:
Dmitriy Mozgovoy
2025-09-13 23:24:16 +03:00
committed by GitHub
parent c26d00f451
commit cf78825e12
2 changed files with 40 additions and 11 deletions
+27
View File
@@ -489,5 +489,32 @@ describe('supports fetch with nodejs', function () {
assert.strictEqual(data, 'OK');
});
it('should use current global fetch when env fetch is not specified', async() => {
const globalFetch = fetch;
fetch = async () => {
return {
headers: {
foo: '1'
},
text: async () => 'global'
}
};
try {
server = await startHTTPServer((req, res) => res.end('OK'));
const {data} = await fetchAxios.get('/', {
env: {
fetch: undefined
}
});
assert.strictEqual(data, 'global');
} finally {
fetch = globalFetch;
}
});
});
});