unit-testing
/unit-testing
How to run and write unit tests in this workspace (Vitest, colocated .spec.ts files, mocked native globals). Use when writing, changing, or running tests.
- Author
- nativescript ↗
- Repository
- nativescript ↗
- Licence
- MIT
- Last repository change
- 24.10.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
How to run and write unit tests in this workspace (Vitest, colocated .spec.ts files, mocked native globals). Use when writing, changing, or running tests.
Original author description
How to run and write unit tests in this workspace (Vitest, colocated .spec.ts files, mocked native globals). Use when writing, changing, or running tests.
How it works
- Running
- Writing
- Environment Constraints
SKILL.md preview
--- name: unit-testing description: How to run and write unit tests in this workspace (Vitest, colocated .spec.ts files, mocked native globals). Use when writing, changing, or running tests. --- # Unit Testing Tests are `*.spec.ts` files colocated with the source they cover, written with Vitest and run per package through Nx. See [WritingUnitTests.md](./references/WritingUnitTests.md) for the full guide. ## Running ```bash npx nx run core:test # all core tests npx nx run core:test -t 'Name' # isolate by describe/it name npx nx run core:test --watch # watch mode ``` Use `-t` to run only the tests related to your change first; run the full package target before finishing. ## Writing - Use the standard Vitest API (`describe`, `it`, `expect`, `beforeEach`, `vi`). Globals are enabled, so imports from `vitest` are optional — match the style of neighboring specs. - Place the spec next to the module: `packages/core/xml/index.spec.ts` covers `packages/core/xml/index.ts`. - Every behavior change in shared (non-platform-specific) logic should add or extend a spec. ## Environment Constraints - Tests run in Node, not on a device. `packages/core/vitest.setup.ts` stubs the platform globals (`__IOS__`, `__ANDROID__`, minimal `NSObject`-style mocks) so modules can load — real iOS/Android APIs do NOT exist here. - If a test needs more native surface, extend the mocks in `vitest.setup.ts`; do not stub natives inline per spec. - Behavior that depends on the real native runtime cannot be unit tested — it belongs in the `apps/automated` e2e suite, which requires a simulator/emulator. Do not attempt to run it unless explicitly asked. - Keep tests deterministic: no network calls, no timing-sensitive assertions without fake timers (`vi.useFakeTimers()`).
Files in this package (2)
- SKILL.md 2 KB
- references/WritingUnitTests.md 1 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · nativescript/nativescript | 100 | MIT |
| open-agentic-catalog/open-agentic-catalog | 100 | Apache-2.0 |
| gathertown/eng-workflow | 100 | MIT |
| reddygopalkrishna/developer-agent-skills | 100 | MIT |
| petrkindlmann/qa-skills | 100 | MIT |
| MARUCIE/openclaw-foundry | 95 | MIT |
| Tyler-R-Kendrick/agent-skills | 95 | MIT |
| kid-sid/codex-spellbook | 95 | MIT |
| OKHP3/skillz | 90 | MIT |
Database snapshot: 13.11.2026 · package version 7be5c1fa5e0e (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100frontend-testing
Generate Vitest + React Testing Library tests for frontend components, hooks, and utilities. Triggers on testing, spec files, coverage, Vitest, RTL, unit tests, integration tests, or write/review test requests. - 90Vitest
Expert guidance for Vitest testing framework including unit tests, integration tests, mocking, coverage, React Testing Library integration, and TypeScript testing. Use this when writing tests for Vite-based applications. - 100frontend-testing
Generate Vitest + React Testing Library tests for Dify frontend components, hooks, and utilities. Triggers on testing, spec files, coverage, Vitest, RTL, unit tests, integration tests, or write/review test requests. - 100typescript-testing
TypeScript testing patterns with Jest/Vitest including unit tests, integration tests, mocking strategies, and coverage. Use when writing TypeScript tests. - 85vitest
Use for Vitest in TypeScript projects (Node, bun, React/Next.js, Effect): write, run, or debug unit/component tests, mocks, testing utilities, and coverage. - 100vitest-testing-patterns
Write tests using Vitest and React Testing Library. Use when creating unit tests, component tests, integration tests, or mocking dependencies. Activates for test file creation, mock patterns, coverage, and testing best practices.