dromse / obsidian-gamified-tasks

Gamify your task management with rewards system, craft your tasks by tags.
MIT License
29 stars 1 forks source link

Test coverage for plugin functionality #15

Closed dromse closed 2 months ago

dromse commented 3 months ago

It will be good insight to add tests, because releasing everytime when found new bug and trying to review all code to find bug before releasing is overwhelming.

So this issue is dedicated to search good test framework and list of tests for plugin.

dromse commented 2 months ago

Test technology to use

For unit tests I consider to use Test runner | Node.js v21.7.3 Documentation. For e2e I'm currently in active-searching what to use.

Links

dromse commented 2 months ago

I discovered that Native Test Runner doesn't provide check test coverage for all project, just only for used files in tests. From my perspective I think it would be useful to get test coverage from all project {.ts,.tsx} files, therefore I want to find utils to get code coverage using Native Test Runner, if it doesn't not exist or this cannot be provided with current Test Runner support I will prefer to switch to another testing library.

dromse commented 2 months ago

I discovered that I can get report from all project by using c8: bcoe/c8: output coverage reports using Node.js' built in coverage

Edit: But I have an issue using it with typescript, I use tsx method from this comment. I run

// in scripts
"test": "node --import tsx --test tests/**/*.ts",
"test:coverage": "c8 pnpm test". 

And run

pnpm test:coverage

image

I'm almost there but the problem is that it shows full code coverage, but that's wrong!

// Added `--experimental-test-coverage`
"test": "node --import tsx --experimental-test-coverage --test tests/**/*.ts",

And run

pnpm test

image

dromse commented 2 months ago

I followed the advice from this comment and downgrade version tsx to 4.2.1 and it starts to work, impressive! image

dromse commented 2 months ago

Now I want to add some e2e tests, What I found for it:

dromse commented 2 months ago

I installed webdriverio and attempt to run an example test but there are conflict between chromedirvers 124 (from electron or webdriverio) and 120 from obsidian. I installed 120 version of chromedriver from here. But I cannot figure out how to proper set up it inside capabilities in wdio.conf.ts.

dromse commented 2 months ago

I currently don't plan to add e2e functionality to this plugin. So I close this issue.