Is it possible to get some examples on how to test the di container?
Since the main goal of di is to invert control, which means isolate components for testing--a little guide to show how vitest/jest could use it would help adoption. By adoption, I mean "how do I test this thing?"
Yeah, so the current state of things is that I started this project back when it was unclear there'd be any reasonable way to test things within Obsidian itself, what with not wanting to muck about in either emulating Obsidian or automating it. And my goals for the DI were never about testing, but about making it possible to reuse components across different plugins, and write plugin features without coupling to global crud like a single settings class or plugin interface. Ophidian Core is just there to provide reusable abstractions and boilerplate-removers over the Obsidian API.
What things have evolved to at this point is that testing usually happens in places outside Core. The Uneventful library on which Core is now based has its own tests, and I am now beginning to move away from the DI model I started with. Instead of subclassing Obsidian stuff, I will where possible extend them with Extensions. So instead of e.g. making a plugin-level Service, you define the service as an extension of the plugin. That is, MyService.for(plugin) rather than plugin.use(MyService). This approach is actually easier to do mocks for than the current DI framework, since you don't have to recreate or reset so much stuff globally.
As part of this work, I'm trying to refactor things so that between Core's setPlugin() and Uneventful's newRoot() it should be possible to reset the entire Core environment between tests, but that process is far from done. There are probably still a bunch of globals that don't get reset by that yet.
No timeline on when any of this gets done, though, it's pretty much all blocked on funding at the moment.
Okay. I'll keep an eye out then. It's just that a simple version of di with minimal testing is such a boon.