jymchng/injectable/testing-injectable

Claude Code and agent skill by jymchng/injectable

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Tests code that uses injectable for dependency injection. Use when writing unit or integration tests that need mock services, pre-built instances, or container isolation.

Install

npx vskill@latest install jymchng/injectable/testing-injectable

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as majiayu000/claude-skill-registry/testing-injectable.

Testing with injectable

Pre-built mock instances

rust
use injectable::prelude::*;
#[derive(Clone, Default)]
struct MockDb { calls: Arc<AtomicUsize> }
let container = Container::builder()
.register(DynProvider::from_value(MockDb::default()))
.build().await?;
let db: MockDb = container.resolve_external().await?;

Optional dependency patterns

rust
// In tests, leave optional deps unregistered — they resolve to None.
let container = Container::builder().build().await?;
let ctx = container.context();
let maybe: Option<Inject<MetricsBackend>> = ctx.extract().await?;
assert!(maybe.is_none());

Container per test (isolation)

rust
#[tokio::test]
async fn test_user_service() {
// Each test gets its own fresh container.
let container = Container::builder()
.register(DynProvider::from_value(MockDatabase::default()))
.build().await.unwrap();
let svc = container.resolve::<UserService>().await.unwrap();
// …
}

Verify singleton semantics

rust
#[tokio::test]
async fn test_singleton() {
let container = Container::builder().build().await.unwrap();
let ctx = container.context();
let a: Inject<Database> = ctx.extract().await.unwrap();
let b: Inject<Database> = ctx.extract().await.unwrap();
assert!(a.ptr_eq(&b), "Database must be a singleton");
}

Test registered types

rust
let container = Container::builder().build().await.unwrap();
assert!(container.registered_types().contains(&"UserService"));

Test missing dependency

rust
let result = container.try_resolve::<UnregisteredService>().await.unwrap();
assert!(result.is_none());

Test lifecycle hooks ran

rust
static POST_CONSTRUCT_CALLED: AtomicBool = AtomicBool::new(false);
struct TestService;
#[injectable]
impl TestService {
#[injectable(ctor)] fn new() -> Self { Self }
#[injectable(post_construct)] fn init(&self) { POST_CONSTRUCT_CALLED.store(true, Ordering::SeqCst); }
}
let container = Container::builder().build().await.unwrap();
Inject::<TestService>::extract(container.context()).await.unwrap();
assert!(POST_CONSTRUCT_CALLED.load(Ordering::SeqCst));

See guides/10-testing.md.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/jymchng/injectable/testing-injectable/badge)](https://verified-skill.com/skills/jymchng/injectable/testing-injectable)

Something wrong with this skill or its page? Tell us.