Skip to content

Commit

Permalink
fix(test): skip fetch tests if global fetch function is not available;
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalBrainJS committed Apr 27, 2024
1 parent 1e5552a commit c0392c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/adapters/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const resolvers = {
stream: (res) => res.body
};

['text', 'arrayBuffer', 'blob', 'formData'].forEach(type => [
isFetchSupported && ['text', 'arrayBuffer', 'blob', 'formData'].forEach(type => [
resolvers[type] = utils.isFunction(Response.prototype[type]) ? (res) => res[type]() : (_, config) => {
throw new AxiosError(`Response type ${type} is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/adapters/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const fetchAxios = axios.create({
let server;

describe('supports fetch with nodejs', function () {
before(function () {
if (typeof fetch !== 'function') {
this.skip();
}
})

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (90% of all statements in
the enclosing function
have an explicit semicolon).

afterEach(async function () {
await stopHTTPServer(server);

Expand Down

0 comments on commit c0392c9

Please sign in to comment.