Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

test: add vitest as test framework and port current tests #977

Merged
merged 13 commits into from
Jan 17, 2025

Conversation

pano9000
Copy link
Member

Hi,

this PR aims to introduce vitest as test framework for the project – replacing the "previous selfmade test runner" and "jasmine".

See discussion here for more details
https://github.com/orgs/TriliumNext/discussions/925

Additional bonus:
We now have test coverage reports, by using npm run test-coverage

@eliandoran
Copy link
Contributor

eliandoran commented Jan 17, 2025

@pano9000 , kind reminder that you have write rights on the repo. You can push directly on a branch on TriliumNext/Notes instead of on your fork.
This will also make it easier for me to checkout the branches without having to use the GitHub API.

Copy link
Contributor

@eliandoran eliandoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job.

Two tests are failing on my side, on Windows, but it's a pretty good start.

@eliandoran eliandoran merged commit 7fc5f9a into TriliumNext:develop Jan 17, 2025
1 check passed
@pano9000
Copy link
Member Author

Good job.

Two tests are failing on my side, on Windows, but it's a pretty good start.

I wonder: which ones are failing?

@eliandoran
Copy link
Contributor

eliandoran commented Jan 18, 2025

@pano9000 , since the last PRs were merged, only one of them is failing:

 FAIL  spec-es6/data_dir.spec.ts > data_dir.ts unit tests > #getPlatformAppDataDir() > w/ win32 and no APPDATA set it should return 'null'      
AssertionError: expected false to be truthy

- Expected
+ Received

- true
+ false

 ❯ spec-es6/data_dir.spec.ts:84:32
     82|                 const actual = getPlatformAppDataDir(...value);
     83|                 const result = isExpected(actual);
     84|                 expect(result).toBeTruthy();
       |                                ^
     85|             });
     86|         });

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯


 Test Files  1 failed | 12 passed | 1 skipped (14)
      Tests  1 failed | 133 passed | 8 skipped | 5 todo (147)
   Start at  17:05:37
   Duration  7.79s (transform 15.34s, setup 0ms, collect 44.70s, tests 179ms, environment 3ms, prepare 6.10s)

The tests for the directories appear a bit complicated, especially with the isExpected. Why not expect(result).toBe(expected)?

@pano9000
Copy link
Member Author

that was mainly, because those tests were written with the mini_test test runner and without mocks, so I had to do some tiny trickery, to avoid duplicating the test function and able to use the forEach loop here.

Now that we have the mocks -> I've simplified it a bit for you ;-)

Regarding the failing test: that is interesting – will need to check on a Windows machine some time

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants