Coding
PromptBeginner5 minmarkdown
Nano Banana Pro
Agent skill for nano-banana-pro
7
- **Use `yarn`** instead of `npm` for all package management commands
Sign in to like and favorite skills
yarn instead of npm for all package management commandsnx for running most commands (build, test, lint, etc.)
yarn nx run @navios/core:build, yarn nx test @navios/core.mts extension for all TypeScript files (ES module syntax)*.spec.mts*.spec-d.mtsyarn nx lint <project> after making changesimport { asyncInject, Container, inject, Injectable } from '@navios/di' import { afterEach, beforeEach, describe, expect, it } from 'vitest' describe('MyService', () => { let container: Container beforeEach(() => { container = new Container() }) afterEach(async () => { await container.dispose() }) it('should do something', async () => { @Injectable() class TestService { // ... } const service = await container.get(TestService) expect(service).toBeDefined() }) })
Container in beforeEachcontainer.dispose() in afterEachRegistry when isolating test services@Injectable() classes inside test blocks (not at module level) to avoid cross-test pollutioninject() for synchronous property injectionasyncInject() for async property injectionexpect(inst1).toBe(inst2))expect(inst1).not.toBe(inst2))onServiceInit, onServiceDestroy) explicitlyimport { InjectionToken } from '@navios/di' import { TestContainer } from '@navios/di/testing' const container = new TestContainer() // Bind value const TOKEN = InjectionToken.create<string>('token') container.bind(TOKEN).toValue('mock-value') // Bind class container.bind(SomeToken).toClass(MockClass) // Clear between tests await container.clear()
@Injectable() class MyService { // Synchronous injection - service must already be initialized private readonly userService = inject(UserService) // Async injection - can wait for initialization (useful for circular dependencies) private readonly apiService = asyncInject(ApiService) // Optional injection - returns null if service fails private readonly optionalService = optional(OptionalService) }