obsidian-testing-framework/README.md

33 lines
858 B
Markdown
Raw Permalink Normal View History

2024-10-24 15:04:58 -04:00
# the Obsidian Testing Framework
2024-10-22 15:32:25 -04:00
2024-10-24 15:04:58 -04:00
## what is this?
this is a library that (finally!) lets you end-to-end test your obsidian plugins.
it uses [playwright](https://playwright.dev/docs/intro) to interact with obsidian,
which is an Electron app under the hood.
## great! how do i use it?
### basic usage
```ts
2024-10-24 21:32:24 -04:00
import {test} from "obsidian-testing-library";
2024-10-24 15:04:58 -04:00
test('obsidian app url', async ({ page }) => {
console.log(page.url());
expect(/obsidian\.md/i.test(page.url())).toBeTruthy()
});
```
### usage with the `app` instance
```ts
test("idk", async({page}) => {
console.log("idk")
2024-10-24 21:32:24 -04:00
let tfile = await doWithApp(page, async (app) => {
2024-10-24 15:04:58 -04:00
return app.metadataCache.getFirstLinkpathDest("Welcome", "/");
});
2024-10-24 21:32:24 -04:00
expect(tfile.basename).toEqual("Welcome")
2024-10-24 15:04:58 -04:00
})
```
### other utilities
see `src/util.ts` for the currently included utilities and their documentation.