Replies: 4 comments
-
Yes, adding tests is something I've been wanting to do for a while but haven't found the time to do. https://github.com/obsidianmd/obsidian-api/issues/13#issuecomment-1003880942 seems helpful, in case anyone is interested in developing a PR. |
Beta Was this translation helpful? Give feedback.
-
I introduced Jest as the testing framework and attempted to write a test. I found that since we import resources from the obsidian package in "editor_utils.ts", it is impossible to test functions that depend on the resources in "editor_utils.ts". That is, we are unable to test the function |
Beta Was this translation helpful? Give feedback.
-
I leave the way to setup Jest here:
/** @type {import('ts-jest').JestConfigWithTsJest} **/
module.exports = {
testEnvironment: "jest-environment-jsdom",
transform: {
"^.+.tsx?$": ["ts-jest",{}],
},
moduleNameMapper: {
"^src/(.+)$": "<rootDir>/src/$1",
},
}; |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking a look!
I think we can remove the references to Workspace and MarkdownView in "editor_utils.ts" if we remove the That just leaves the reference to Platform in |
Beta Was this translation helpful? Give feedback.
-
@artisticat1
Writing tests every time you fix a bug or add a new feature is a good practice to ensure that the behavior doesn't change unintentionally. Could you please introduce a framework for writing tests? I found some articles about automated tests of obsidian plugins here.
Beta Was this translation helpful? Give feedback.
All reactions