-
Notifications
You must be signed in to change notification settings - Fork 159
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
Fill "How to add automated tests to your plugin" page #754
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I have marked some things I noticed while reading through it.
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Show resolved
Hide resolved
|
||
```ts | ||
// myplugin.ts | ||
import { Notice } from "obsidian"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use explicit import type { Notice } from "obsidian";
notation. Adding "verbatimModuleSyntax": true,
to the TS config is a good idea anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a point, but I still would like to keep it this way. If one uses a obsidian dependency, i.e. Notice
, VSC creates an auto-import like this. While a type import would be cleaner, it is not necessary to use them to get the tests running and I'd like to only use and mention mandatory steps to keep the complexity lower.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is fair. Though without explicit type imports, you are at the mercy of whatever the TS transpiler in this setup does.
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
link obsidian example plugin github repository
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed a few more small things, mostly with the code examples around inconsistent code style.
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
Sorry for that, I should have invested 5 minutes to configure prettier in the example plugin after all .. :) If I might ask you to have a look again? Thanks for your time! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there XD
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
04 - Guides, Workflows, & Courses/Guides/How to add automated tests to your plugin.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@claremacrae Hello Clare, sorry for pinging you directly. I hope it does not bother you. If your time allows I'd be grateful if you could have a look if it's feasible to merge this PR - I'd like to clean up https://publish.obsidian.md/hub/04+-+Guides%2C+Workflows%2C+%26+Courses/Guides/How+to+test+plugin+code+that+uses+Obsidian+APIs as a follow up PR as soon as this one is merged. Thanks alot for your time! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant work - thank you very much indeed!
// example.spec.ts | ||
describe('MyPlugin Tests', () => { | ||
|
||
it('should be able to execute test', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will go ahead and merge, but looking at this file in PyCharm, these are among several that have NBSP
characters rather than ordinary spaces...
It probably won't matter in the published docs though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a note to check and fix it in my follow up PR, thanks for pointing it out :)
|
||
%% Hub footer: Please don't edit anything below this line %% | ||
|
||
# This note in GitHub | ||
|
||
<span class="git-footer">[Edit In GitHub](https://github.dev/obsidian-community/obsidian-hub/blob/main/04%20-%20Guides%2C%20Workflows%2C%20%26%20Courses/Guides/How%20to%20add%20automated%20tests%20to%20your%20plugin.md "git-hub-edit-note") | [Copy this note](https://raw.githubusercontent.com/obsidian-community/obsidian-hub/main/04%20-%20Guides%2C%20Workflows%2C%20%26%20Courses/Guides/How%20to%20add%20automated%20tests%20to%20your%20plugin.md "git-hub-copy-note") | [Download this vault](https://github.com/obsidian-community/obsidian-hub/archive/refs/heads/main.zip "git-hub-download-vault") </span> | ||
<span class="git-footer">[Edit In GitHub](https://github.dev/Obsidian-community/Obsidian-hub/blob/main/04%20-%20Guides%2C%20Workflows%2C%20%26%20Courses/Guides/How%20to%20add%20automated%20tests%20to%20your%20plugin.md "git-hub-edit-note") | [Copy this note](https://raw.githubusercontent.com/Obsidian-community/Obsidian-hub/main/04%20-%20Guides%2C%20Workflows%2C%20%26%20Courses/Guides/How%20to%20add%20automated%20tests%20to%20your%20plugin.md "git-hub-copy-note") | [Download this vault](https://github.com/Obsidian-community/Obsidian-hub/archive/refs/heads/main.zip "git-hub-download-vault") </span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's curious that the casing has changed here but the links still work, and will get overwritten on the next weekly automated update, so it's not a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my fault, sorry for it. I did a find & replace on obsidian to capitalize that - I thought I reverted the changes in the footer but seemingly I did not. Good to know it'll heal itself!
And thank you very much @mProjectsCode for the thorough reviews too! |
Edited
Hello,
I created a guide how to integrate jest to the obsidian example plugin and how to deal with the obsidian API when running code in a test environment to fill in the stub page "How to add automated tests to your plugin".
I tested the guide via a Windows Sandbox but would very appreciate if somebody else undertakes the steps to make sure that it's working as expected.
I was unsure what to do with https://publish.obsidian.md/hub/04+-+Guides%2C+Workflows%2C+%26+Courses/Guides/How+to+test+plugin+code+that+uses+Obsidian+APIs and if I should update it, as well. I'd love your input here. "Issue 13" of the obsidian API is not available anymore and the links under "Other people's suggestions" are not reachable. However, I am not quite aware if the guide now provide enough guidance to remove the section altogether or what's the best course of action is.
If you have pointers to improve reading flow or wording, it'd be very appreciated. Furthermore I have no experience with Obsidian Publish and do not know if I should have avoided any kind of syntax - I only controlled the look and feel in Obsidian itself.
Also, since this is my first contribution, I hope it was correct to change the tag to "evergreen".
Regards
Added
Checklist
.md
extension