Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce testing with Vitest #745

Closed
wants to merge 2 commits into from

Conversation

tamiroh
Copy link
Contributor

@tamiroh tamiroh commented Jul 2, 2024

This pull request sets up an environment for testing with Vitest ⚡. In addition, as a first step, I have added some tests for utils.

export default defineConfig({
test: {
alias: {
obsidian: path.resolve(__dirname, "mocks/obsidian.ts"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

obsidian needs to be mocked. The functions I have tested in this PR does not depend on obsidian, so it is currently an empty file.

See: vitest-dev/vitest#4029 (comment)

@tamiroh tamiroh marked this pull request as ready for review July 2, 2024 14:40
@Vinzent03
Copy link
Owner

Thanks for your effort to add tests to this plugin. However, I would greatly appreciate, if you would open an issue to discuss such huge decisions beforehand. I've thought a lot about adding tests, but it's not that easy, as many parts are highly integrated with Obsidian or the actual git cli. Testing some independent helper methods like you did is probably still a great idea.

I haven't worked much with javascript testing frameworks, but from looking at other plugins, I would rather use jest instead of vitest, because jest is more popular. From what I quickly read, using vitest makes more sense if we would use vite as well.

@tamiroh
Copy link
Contributor Author

tamiroh commented Jul 7, 2024

OK, this was a bit of an sudden proposal, and I didn't explain it well enough. I am closing this pull request for now and will open an Issue again. Thank you for your review!

As for Jest, Jest is certainly the more mature choice, but I think Vitest works better with ESM & TypeScript, and the API is compatible with Jest, so if you don't like it, it's actually not difficult to switch to Jest.

@tamiroh tamiroh closed this Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants