diff --git a/meta/testing/jest.config.cjs b/meta/testing/jest.config.cjs index 59bc8e0..10afdbb 100644 --- a/meta/testing/jest.config.cjs +++ b/meta/testing/jest.config.cjs @@ -1,22 +1,24 @@ module.exports = { + // general + rootDir: '../../', + preset: 'ts-jest/presets/default-esm', + modulePaths: ['/src/'], + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + // coverage collectCoverageFrom: ["src/**/*.ts", "!**/__tests__/**/*"], - coveragePathIgnorePatterns : [ + coveragePathIgnorePatterns: [ "/src/index.ts", "/src/constants.ts", "/src/helpers/cache/migrations/index.ts" ], - moduleNameMapper: { - '^(\\.{1,2}/.*)\\.js$': '$1', - }, - modulePaths: ['/src/'], - rootDir: '../../', + // jest setupFilesAfterEnv: ['/meta/testing/jest.setup.cjs'], + maxWorkers: "50%", testRegex: '(/__tests__/.*\\.spec)\\.ts?$', testTimeout: 25000, - preset: "ts-jest/presets/default-esm", - verbose: false, - maxWorkers: "50%", transform: { "^.+\\.[tj]s$": "ts-jest" - }, + } }; diff --git a/meta/testing/jest.setup.cjs b/meta/testing/jest.setup.cjs index d5740d0..1a62801 100644 --- a/meta/testing/jest.setup.cjs +++ b/meta/testing/jest.setup.cjs @@ -1 +1,8 @@ jest.retryTimes(0); + +// Mock @atproto/api with the actual implementation to bypass some type errors such as +// TypeError: api_1.default.RichText is not a constructor. + +jest.mock("@atproto/api", () => ({ + ...jest.requireActual("@atproto/api"), +})); diff --git a/package-lock.json b/package-lock.json index 6c9890a..c3df015 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "touitomamout", - "version": "1.5.0", + "version": "1.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "touitomamout", - "version": "1.5.0", + "version": "1.6.0", "hasInstallScript": true, "license": "AGPL-3.0-or-later", "dependencies": { diff --git a/src/helpers/post/make-bluesky-post.ts b/src/helpers/post/make-bluesky-post.ts index 34af73a..1434968 100644 --- a/src/helpers/post/make-bluesky-post.ts +++ b/src/helpers/post/make-bluesky-post.ts @@ -1,4 +1,4 @@ -import { BskyAgent, RichText } from "@atproto/api"; +import bsky, { BskyAgent } from "@atproto/api"; import { Tweet } from "@the-convocation/twitter-scraper"; import { BLUESKY_IDENTIFIER } from "../../constants.js"; @@ -53,7 +53,7 @@ export const makeBlueskyPost = async ( : undefined; } - const post = new RichText({ text: tweet.text! }); + const post = new bsky.RichText({ text: tweet.text! }); await post.detectFacets(client); // automatically detects mentions and links return { diff --git a/src/services/bluesky-sender.service.ts b/src/services/bluesky-sender.service.ts index 63a32e2..2c59bcc 100644 --- a/src/services/bluesky-sender.service.ts +++ b/src/services/bluesky-sender.service.ts @@ -1,4 +1,4 @@ -import { BskyAgent, RichText } from "@atproto/api"; +import bsky, { BskyAgent } from "@atproto/api"; import { Ora } from "ora"; import { DEBUG, VOID } from "../constants.js"; @@ -110,7 +110,7 @@ export const blueskySenderService = async ( * If the tweet is long, each child chunk will reference the previous one as replyId. */ for (const chunk of post.chunks) { - const richText = new RichText({ text: chunk }); + const richText = new bsky.RichText({ text: chunk }); await richText.detectFacets(client); const data: {