So, I’m working on developing a plugin to integrate Selenium into Obsidian (still a WIP), and I’ve just discovered something pretty handy.
So Obsidian stores the vaults that it has loaded into it’s AppData folder under 2 .json files.
The first is the main obsidian.json file. The second is a [vault_id]
.json file.
The files are pretty simple. The obsidian.json file contains all of the vaults that it has loaded along with a ts
field which is the vault’s timestamp. The [vault_id]
.json file contains the JSON object used to open the Electron window.
Now, I’ve been wanting to create a unit test for my plugin, but have been having difficulty getting one setup. My unit test design has been to clone a vault into a test directory and load the plugin into it, then open a test README.md file in it.
The last part has been the part that I’ve been struggling with. I was trying to use obsidian URI’s to open the new vault, but found that if Obsidian has never opened that vault before, the obsidian URI doesn’t work.
What I found was that you could add your own entry to the obsidian.json file, and create your own [vault_id]
.json file, then use the obsidian uri to open the file.
Another interesting thing I found was that this section of the Obsidian URI docs isn’t exactly accurate.
Obsidian internally uses random 16-character ids for the vault id, but that doesn’t mean that it has to be. In fact when I created my own entry in the obsidian.json file and creating a [vault_id]
.json file, I was using vault_ids with 20+ characters (git branch name + timestamp)