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

Add Tests for Creating a New Project #249

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

b-camphart
Copy link
Contributor

I tried to keep this as small as possible, but I ended up creating a whole little ad-hoc integration test framework 😅

To summarize what's happening here:

  • I extracted logic from store-vault-sync.ts and draft-utils.ts into the drafts.ts file to isolate it from the obsidian API. (re-exported functions in-place so preserve existing imports in the rest of the code)
  • I created an interface that could be mocked between that logic and the obsidian API.
  • Created unit tests for Creating a New Project (from both the plugin's API, and by creating a new index file)
  • To ensure that the wrapper around the obsidian API (VaultDirectory) worked the way I expected, and that the mocked version I'm using in unit tests worked the same way, I created a contract test and, well, an integration test framework. This allows us to actually run tests within obsidian, but only when we actually run the specific build config. In the normal dev and prod build configurations, the tests won't be imported by anything, and thus not included.

I recognize that this is still probably a lot to look over, so, if you'd prefer that I split this into two PRs: one for the int test framework stuff, and the other for actually adding the Create New Project unit tests, let me know :)

@kevboh
Copy link
Owner

kevboh commented Mar 5, 2024

Give me a few days to find a good chunk of time to review this. Thanks for putting in all this effort!

@b-camphart
Copy link
Contributor Author

Take your time, I know you're busy with the new job 🙂

@b-camphart
Copy link
Contributor Author

Hey @kevboh I know this one was a really big chunk to try to review. My thoughts on testing in obsidian have changed a little since then, and I'd be happy to try to take another stab at this (and break it into smaller bits for you). Let me know if you'd like me to give that a go, or if you're still thinking about reviewing this one :)

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