BlueSky Bot: Give It Up For Day 15
back to /index

BlueSky Bot: Give It Up For Day 15

April 8th, 2025

` Github Repository: https://github.com/pbkay/bsky-giveitupforday15-bot

I love the meme since years ago and look forward to it every month on my social media. Having wanted to build my own bot and with BlueSky’s API being open, this was a great opportunity for a fun personal project.

The bot uses Typescript, Jest, BlueSky’s API, and GitHub Actions to schedule cron jobs.

Challenges: My project includes Jest unit tests, which may be a bit excessive for a project of this size, but having previously found mocking challenging, I saw it as an opportunity to improve my mocking skills by incorporating testing to push myself to get better at it.

The hardest part about mocking, especially with Typescript, is getting the types right when initializing the object you want to mock.

After struggling quite a bit, I reached out to the helpful Typescript community on Discord and they provided guidance and this snippet of code:

jest.mock('@atproto/api');

const mockAgent = {
    login: jest.fn(),
} as unknown as jest.MockedObject<AtpAgent>

As many has said before: the importance of asking for help is very powerful. The provided code cleared up all my questions and enabled me to have a starting point to write tests for the rest of my functions. The project was smooth sailing afterwards :)