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:
@@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user