souvikinator / notion-to-md

Convert notion pages, block and list of blocks to markdown (supports nesting and custom parsing)
https://www.npmjs.com/package/notion-to-md
MIT License
1.12k stars 91 forks source link

Missing tests #10

Open Souvikns opened 2 years ago

Souvikns commented 2 years ago

In the context of testing I would like to talk about two things

  1. Hitting Notion API to fetch block contents now to successfully run this tests we will be depending on notion API and need an API key and also the database has to follow a pattern which will be hard to test locally every time anyone clones the repo.
  2. Secondly we are parsing the block JSON object and converting it into markdown flavored string, I think this is something we can test effectively and should mock the block data structure to do so.
scopsy commented 2 years ago

I think we can do unit tests with jest or other testing framework and just mock the structure of notion blocks. In this way we can make sure that the output is as expected.

souvikinator commented 2 years ago

I'm not sure if that'll work as each method depends on the notion client SDK (excluding toMarkdownString). So internally recursive API calls are being made to fetch the child blocks. I guess we can create a dummy notion document and pass the auth token as an environment variable to the CI/CD. If someone wants to run locally then probably they have to provide theirs.

scopsy commented 2 years ago

I've created a base jest infra in #17 we can expand it and create mocks to the notion client API easily with jest.