mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
refactor(rest): switch api to fetch-like and provide strategies (#9416)
BREAKING CHANGE: NodeJS v18+ is required when using node due to the use of global `fetch` BREAKING CHANGE: The raw method of REST now returns a web compatible `Respone` object. BREAKING CHANGE: The `parseResponse` utility method has been updated to operate on a web compatible `Response` object. BREAKING CHANGE: Many underlying internals have changed, some of which were exported. BREAKING CHANGE: `DefaultRestOptions` used to contain a default `agent`, which is now set to `null` instead.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable id-length */
|
||||
/* eslint-disable promise/prefer-await-to-then */
|
||||
import { performance } from 'node:perf_hooks';
|
||||
import { setInterval, clearInterval, setTimeout } from 'node:timers';
|
||||
import { setInterval, clearInterval } from 'node:timers';
|
||||
import { MockAgent, setGlobalDispatcher } from 'undici';
|
||||
import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor.js';
|
||||
import { beforeEach, afterEach, test, expect, vitest } from 'vitest';
|
||||
@@ -492,7 +492,7 @@ test('server responding too slow', async () => {
|
||||
|
||||
const promise = api2.get('/slow');
|
||||
|
||||
await expect(promise).rejects.toThrowError('Request aborted');
|
||||
await expect(promise).rejects.toThrowError('aborted');
|
||||
}, 1_000);
|
||||
|
||||
test('Unauthorized', async () => {
|
||||
@@ -570,8 +570,8 @@ test('abort', async () => {
|
||||
controller.abort();
|
||||
|
||||
// Abort mid-execution:
|
||||
await expect(bP2).rejects.toThrowError('Request aborted');
|
||||
await expect(bP2).rejects.toThrowError('aborted');
|
||||
|
||||
// Abort scheduled:
|
||||
await expect(cP2).rejects.toThrowError('Request aborted');
|
||||
await expect(cP2).rejects.toThrowError('Request aborted manually');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user