R004

Detect it() blocks lacking assertions in .ets, .ts, and .js test files.

31|6|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill r004
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: R004
Source: https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/check-test-code-quality/rules/R004
Command: npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill r004

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It detects invalid unit/integration test cases where an it() block contains no assertion, preventing the test from actually verifying behavior.

Core Features & Use Cases

  • Assertion Presence Verification: Flags it() blocks in .ets, .ts, and .js files that lack any effective assertion.
  • Indirect Assertion Tracing: Recursively checks local and imported helper functions to determine whether assertions exist through call chains.
  • try-catch Branch Guarding: Ensures assertions exist appropriately within try and catch branches, including detection of missing assertions and gaps in helper functions.

Quick Start

Use the R004 skill to scan your ArkTS/TypeScript/JavaScript test files and report which it() test cases are missing effective assertions.

Frequently Asked Questions about R004

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find unit tests with no assertions in ArkTS or TypeScript test files?

To detect empty unit tests in OpenHarmony or HarmonyOS, scan your .ets, .ts, and .js test files to identify it() blocks that lack effective assertions and prevent tests that cannot validate outcomes.

Does static analysis trace assertions inside imported helper functions for OpenHarmony tests?

Static analysis can trace assertions inside imported helper functions by recursively checking local and imported call chains to determine whether effective assertions exist within the test workflow.

How are try-catch branches validated for missing assertions in JavaScript test cases?

Validating try-catch branches for missing assertions involves ensuring that both try and catch branches contain effective, non-commented assertions, including detecting gaps within called helper functions.

What is an empty test case in HarmonyOS unit testing?

An empty test case in HarmonyOS unit testing is an it() block that contains no effective assertions, meaning the test runs without actually verifying any behavior or outcomes.

Can I scan .ets workflow test files to locate missing assertions?

You can scan .ets workflow test files to locate missing assertions by parsing brace structures outside strings and template literals to accurately flag it() blocks lacking verification logic.

What are the limitations of detecting empty tests in ArkTS test sources?

Limitations of detecting empty tests in ArkTS include relying on accurate brace and structure parsing outside template literals, and recursively tracing assertions through local and imported functions without hitting string false positives.