summaryrefslogtreecommitdiff
path: root/packages/backend/test/utils.ts
diff options
context:
space:
mode:
authorMarie <github@yuugi.dev>2025-05-08 16:09:36 +0000
committerMarie <github@yuugi.dev>2025-05-08 16:09:36 +0000
commitc5f5c6fef07b98ef2aa89e19c7cd70bfecc695e6 (patch)
tree06da4f5e20e9b2fca54e605f3db2fc7fc2526cfd /packages/backend/test/utils.ts
parentmerge: Improve inline quote detection and link previews (resolves #1047 and #... (diff)
parentseparate type imports for Cheerio (diff)
downloadsharkey-c5f5c6fef07b98ef2aa89e19c7cd70bfecc695e6.tar.gz
sharkey-c5f5c6fef07b98ef2aa89e19c7cd70bfecc695e6.tar.bz2
sharkey-c5f5c6fef07b98ef2aa89e19c7cd70bfecc695e6.zip
merge: Replace JSDOM with cheerio (!973)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/973 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
Diffstat (limited to 'packages/backend/test/utils.ts')
-rw-r--r--packages/backend/test/utils.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/packages/backend/test/utils.ts b/packages/backend/test/utils.ts
index 7b69cb04f4..7f2768488f 100644
--- a/packages/backend/test/utils.ts
+++ b/packages/backend/test/utils.ts
@@ -11,11 +11,12 @@ import { inspect } from 'node:util';
import WebSocket, { ClientOptions } from 'ws';
import fetch, { File, RequestInit, type Headers } from 'node-fetch';
import { DataSource } from 'typeorm';
-import { JSDOM } from 'jsdom';
+import { load as cheerio } from 'cheerio';
import { type Response } from 'node-fetch';
import Fastify from 'fastify';
import { entities } from '../src/postgres.js';
import { loadConfig } from '../src/config.js';
+import type { CheerioAPI } from 'cheerio';
import type * as misskey from 'misskey-js';
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
@@ -464,7 +465,7 @@ export function makeStreamCatcher<T>(
export type SimpleGetResponse = {
status: number,
- body: any | JSDOM | null,
+ body: any | CheerioAPI | null,
type: string | null,
location: string | null
};
@@ -495,7 +496,7 @@ export const simpleGet = async (path: string, accept = '*/*', cookie: any = unde
const body =
jsonTypes.includes(res.headers.get('content-type') ?? '') ? await res.json() :
- htmlTypes.includes(res.headers.get('content-type') ?? '') ? new JSDOM(await res.text()) :
+ htmlTypes.includes(res.headers.get('content-type') ?? '') ? cheerio(await res.text()) :
await bodyExtractor(res);
return {